Retain subsection extractor when adding field descriptors with prefix

Closes gh-480
This commit is contained in:
Andy Wilkinson
2018-03-28 09:45:01 +01:00
parent 7924d5fb01
commit 1c08000bcf
5 changed files with 44 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2017 the original author or authors.
* Copyright 2014-2018 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.
@@ -314,6 +314,16 @@ public abstract class AbstractFieldsSnippet extends TemplatedSnippet {
return this.ignoreUndocumentedFields;
}
/**
* Returns the {@link PayloadSubsectionExtractor}, if any, used by this snippet.
*
* @return the subsection extractor or {@code null}
* @since 1.2.4
*/
protected final PayloadSubsectionExtractor<?> getSubsectionExtractor() {
return this.subsectionExtractor;
}
/**
* Returns a model for the given {@code descriptor}.
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2017 the original author or authors.
* Copyright 2014-2018 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,8 +206,8 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet {
combinedDescriptors.addAll(getFieldDescriptors());
combinedDescriptors.addAll(PayloadDocumentation.applyPathPrefix(pathPrefix,
Arrays.asList(additionalDescriptors)));
return new RequestFieldsSnippet(combinedDescriptors, getAttributes(),
isIgnoredUndocumentedFields());
return new RequestFieldsSnippet(getSubsectionExtractor(), combinedDescriptors,
getAttributes(), isIgnoredUndocumentedFields());
}
/**
@@ -226,8 +226,8 @@ public class RequestFieldsSnippet extends AbstractFieldsSnippet {
getFieldDescriptors());
combinedDescriptors.addAll(
PayloadDocumentation.applyPathPrefix(pathPrefix, additionalDescriptors));
return new RequestFieldsSnippet(combinedDescriptors, getAttributes(),
isIgnoredUndocumentedFields());
return new RequestFieldsSnippet(getSubsectionExtractor(), combinedDescriptors,
getAttributes(), isIgnoredUndocumentedFields());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2017 the original author or authors.
* Copyright 2014-2018 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,8 +210,8 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet {
combinedDescriptors.addAll(getFieldDescriptors());
combinedDescriptors.addAll(PayloadDocumentation.applyPathPrefix(pathPrefix,
Arrays.asList(additionalDescriptors)));
return new ResponseFieldsSnippet(combinedDescriptors, this.getAttributes(),
isIgnoredUndocumentedFields());
return new ResponseFieldsSnippet(getSubsectionExtractor(), combinedDescriptors,
this.getAttributes(), isIgnoredUndocumentedFields());
}
/**
@@ -230,8 +230,8 @@ public class ResponseFieldsSnippet extends AbstractFieldsSnippet {
getFieldDescriptors());
combinedDescriptors.addAll(
PayloadDocumentation.applyPathPrefix(pathPrefix, additionalDescriptors));
return new ResponseFieldsSnippet(combinedDescriptors, this.getAttributes(),
isIgnoredUndocumentedFields());
return new ResponseFieldsSnippet(getSubsectionExtractor(), combinedDescriptors,
this.getAttributes(), isIgnoredUndocumentedFields());
}
}