Make new snippet relaxed when adding descriptors to relaxed snippet

Closes gh-400
This commit is contained in:
Andy Wilkinson
2017-07-01 16:25:46 +01:00
parent 214c068ece
commit a84bb0c569
5 changed files with 48 additions and 6 deletions

View File

@@ -305,6 +305,15 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet {
return this.fieldDescriptors;
}
/**
* Returns whether or not this snippet ignores undocumented fields.
*
* @return {@code true} if undocumented fields are ignored, otherwise {@code false}
*/
protected final boolean isIgnoredUndocumentedFields() {
return this.ignoreUndocumentedFields;
}
/**
* Returns a model for the given {@code descriptor}.
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -206,7 +206,8 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet {
combinedDescriptors.addAll(getFieldDescriptors());
combinedDescriptors.addAll(PayloadDocumentation.applyPathPrefix(pathPrefix,
Arrays.asList(additionalDescriptors)));
return new RequestFieldsSnippet(combinedDescriptors, this.getAttributes());
return new RequestFieldsSnippet(combinedDescriptors, getAttributes(),
isIgnoredUndocumentedFields());
}
/**
@@ -225,7 +226,8 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet {
getFieldDescriptors());
combinedDescriptors.addAll(
PayloadDocumentation.applyPathPrefix(pathPrefix, additionalDescriptors));
return new RequestFieldsSnippet(combinedDescriptors, this.getAttributes());
return new RequestFieldsSnippet(combinedDescriptors, getAttributes(),
isIgnoredUndocumentedFields());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -210,7 +210,8 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet {
combinedDescriptors.addAll(getFieldDescriptors());
combinedDescriptors.addAll(PayloadDocumentation.applyPathPrefix(pathPrefix,
Arrays.asList(additionalDescriptors)));
return new ResponseFieldsSnippet(combinedDescriptors, this.getAttributes());
return new ResponseFieldsSnippet(combinedDescriptors, this.getAttributes(),
isIgnoredUndocumentedFields());
}
/**
@@ -229,7 +230,8 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet {
getFieldDescriptors());
combinedDescriptors.addAll(
PayloadDocumentation.applyPathPrefix(pathPrefix, additionalDescriptors));
return new ResponseFieldsSnippet(combinedDescriptors, this.getAttributes());
return new ResponseFieldsSnippet(combinedDescriptors, this.getAttributes(),
isIgnoredUndocumentedFields());
}
}