Polish "Propagate ignoreUndocumentedParamteres with .and()"
See gh-676
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2019 the original author or authors.
|
* Copyright 2014-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -148,8 +148,14 @@ public abstract class AbstractParametersSnippet extends TemplatedSnippet {
|
|||||||
return this.descriptorsByName;
|
return this.descriptorsByName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether to ignore undocumented parameters.
|
||||||
|
* @return {@code true} if undocumented parameters should be ignored, otherwise
|
||||||
|
* {@code false}
|
||||||
|
* @since 2.0.5
|
||||||
|
*/
|
||||||
protected final boolean isIgnoreUndocumentedParameters() {
|
protected final boolean isIgnoreUndocumentedParameters() {
|
||||||
return ignoreUndocumentedParameters;
|
return this.ignoreUndocumentedParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2019 the original author or authors.
|
* Copyright 2014-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -170,7 +170,7 @@ public class PathParametersSnippet extends AbstractParametersSnippet {
|
|||||||
public final PathParametersSnippet and(List<ParameterDescriptor> additionalDescriptors) {
|
public final PathParametersSnippet and(List<ParameterDescriptor> additionalDescriptors) {
|
||||||
List<ParameterDescriptor> combinedDescriptors = new ArrayList<>(getParameterDescriptors().values());
|
List<ParameterDescriptor> combinedDescriptors = new ArrayList<>(getParameterDescriptors().values());
|
||||||
combinedDescriptors.addAll(additionalDescriptors);
|
combinedDescriptors.addAll(additionalDescriptors);
|
||||||
return new PathParametersSnippet(combinedDescriptors, this.getAttributes());
|
return new PathParametersSnippet(combinedDescriptors, this.getAttributes(), isIgnoreUndocumentedParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2019 the original author or authors.
|
* Copyright 2014-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -133,7 +133,8 @@ public class RequestParametersSnippet extends AbstractParametersSnippet {
|
|||||||
public RequestParametersSnippet and(List<ParameterDescriptor> additionalDescriptors) {
|
public RequestParametersSnippet and(List<ParameterDescriptor> additionalDescriptors) {
|
||||||
List<ParameterDescriptor> combinedDescriptors = new ArrayList<>(getParameterDescriptors().values());
|
List<ParameterDescriptor> combinedDescriptors = new ArrayList<>(getParameterDescriptors().values());
|
||||||
combinedDescriptors.addAll(additionalDescriptors);
|
combinedDescriptors.addAll(additionalDescriptors);
|
||||||
return new RequestParametersSnippet(combinedDescriptors, this.getAttributes(), this.isIgnoreUndocumentedParameters());
|
return new RequestParametersSnippet(combinedDescriptors, this.getAttributes(),
|
||||||
|
this.isIgnoreUndocumentedParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2019 the original author or authors.
|
* Copyright 2014-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -159,6 +159,16 @@ public class PathParametersSnippetTests extends AbstractSnippetTests {
|
|||||||
tableWithTitleAndHeader(getTitle(), "Parameter", "Description").row("`a`", "one").row("`b`", "two"));
|
tableWithTitleAndHeader(getTitle(), "Parameter", "Description").row("`a`", "one").row("`b`", "two"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void additionalDescriptorsWithRelaxedRequestParameters() throws IOException {
|
||||||
|
RequestDocumentation.relaxedPathParameters(parameterWithName("a").description("one"))
|
||||||
|
.and(parameterWithName("b").description("two")).document(this.operationBuilder
|
||||||
|
.attribute(RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE, "/{a}/{b}/{c}").build());
|
||||||
|
assertThat(this.generatedSnippets.pathParameters())
|
||||||
|
.is(tableWithTitleAndHeader(getTitle("/{a}/{b}/{c}"), "Parameter", "Description").row("`a`", "one")
|
||||||
|
.row("`b`", "two"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pathParametersWithEscapedContent() throws IOException {
|
public void pathParametersWithEscapedContent() throws IOException {
|
||||||
RequestDocumentation.pathParameters(parameterWithName("Foo|Bar").description("one|two"))
|
RequestDocumentation.pathParameters(parameterWithName("Foo|Bar").description("one|two"))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2019 the original author or authors.
|
* Copyright 2014-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -156,8 +156,9 @@ public class RequestParametersSnippetTests extends AbstractSnippetTests {
|
|||||||
@Test
|
@Test
|
||||||
public void additionalDescriptorsWithRelaxedRequestParameters() throws IOException {
|
public void additionalDescriptorsWithRelaxedRequestParameters() throws IOException {
|
||||||
RequestDocumentation.relaxedRequestParameters(parameterWithName("a").description("one"))
|
RequestDocumentation.relaxedRequestParameters(parameterWithName("a").description("one"))
|
||||||
.and(parameterWithName("b").description("two")).document(this.operationBuilder
|
.and(parameterWithName("b").description("two"))
|
||||||
.request("http://localhost").param("a", "bravo").param("b", "bravo").param("c", "undocumented").build());
|
.document(this.operationBuilder.request("http://localhost").param("a", "bravo").param("b", "bravo")
|
||||||
|
.param("c", "undocumented").build());
|
||||||
assertThat(this.generatedSnippets.requestParameters())
|
assertThat(this.generatedSnippets.requestParameters())
|
||||||
.is(tableWithHeader("Parameter", "Description").row("`a`", "one").row("`b`", "two"));
|
.is(tableWithHeader("Parameter", "Description").row("`a`", "one").row("`b`", "two"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user