Reformatting before fixing the test
(2220)
@@ -41,7 +41,8 @@ import java.lang.annotation.Annotation
@Mixin([RequestMappingSupport])
class ParameterRequiredReaderSpec extends DocumentationContextSpec implements ParameterAnnotationSupport {
- @Shared description = new DescriptionResolver(new MockEnvironment())
+ @Shared
+ def description = new DescriptionResolver(new MockEnvironment())
@Unroll
def "parameters required paramAnnotations using default reader"() {
@@ -51,14 +52,26 @@ class ParameterRequiredReaderSpec extends DocumentationContextSpec implements Pa
methodParameter.getParameterType() >> Object.class
methodParameter.getMethodAnnotation(PathVariable.class) >> paramAnnotations.find { it instanceof PathVariable }
def resolvedMethodParameter =
- new ResolvedMethodParameter(0, "", paramAnnotations, new TypeResolver().resolve(Object.class))
- ParameterContext parameterContext = new ParameterContext(resolvedMethodParameter, new ParameterBuilder(),
- context(), Mock(GenericTypeNamingStrategy), Mock(OperationContext))
+ new ResolvedMethodParameter(
+ 0,
+ "",
+ paramAnnotations,
+ new TypeResolver().resolve(Object.class))
+ ParameterContext parameterContext =
+ new ParameterContext(
+ resolvedMethodParameter,
+ new ParameterBuilder(),
+ context(),
+ Mock(GenericTypeNamingStrategy),
+ Mock(OperationContext))
+
when:
def operationCommand = new ParameterRequiredReader(description)
operationCommand.apply(parameterContext)
+
then:
parameterContext.parameterBuilder().build().isRequired() == expected
+
where:
paramAnnotations | expected
[[required: { -> false }] as ApiParam, pathVariable(false)] | true
@@ -106,8 +119,10 @@ class ParameterRequiredReaderSpec extends DocumentationContextSpec implements Pa
}
}
operationCommand.apply(parameterContext)
+
then:
!parameterContext.parameterBuilder().build().isRequired()
+
where:
paramAnnotations << [
[requestHeader(true, "", "")],
@@ -120,6 +135,7 @@ class ParameterRequiredReaderSpec extends DocumentationContextSpec implements Pa
def "Supports all documentation types"() {
given:
def sut = new ParameterRequiredReader(description)
+
expect:
sut.supports(DocumentationType.SPRING_WEB)
sut.supports(DocumentationType.SWAGGER_12)
