Closed satyavemuri closed 4 years ago
I believe the defaultValue is part of the @Schema
and not the @Parameter
.
See the example below (from this sample project):
@Schema(description = "Test enum object", defaultValue = "TestEnum.C")
@NotNull
@JsonProperty("testEnum")
private TestEnum testEnum = TestEnum.C;
@satyavemuri,
The class io.swagger.v3.oas.annotations.Parameter
is not a springdoc-openapi class.
Please raison your question on the swagger github instead.
Hi @bnasslahsen,
Thanks for the response, I will raise the issue in Swagger Github.
for convenience: https://github.com/swagger-api/swagger-core/issues/4174
We also ran into this issue and were able to make the following workaround
in cases where there was a @Parameter
annotated parameter that also had a @org.springframework.web.bind.annotation.RequestParam
annotation.
@Component
public class DefaultValueParameterCustomizer implements ParameterCustomizer {
@Override
public Parameter customize(Parameter parameterModel, MethodParameter methodParameter) {
RequestParam requestParamAnnotation = methodParameter.getParameterAnnotation(RequestParam.class);
if (requestParamAnnotation != null &&
!ValueConstants.DEFAULT_NONE.equals(requestParamAnnotation.defaultValue())) {
String defaultValue = requestParamAnnotation.defaultValue();
parameterModel.setExtensions(new HashMap<>());
parameterModel.getExtensions().put("default", defaultValue);
}
return parameterModel;
}
}
Describe the bug
Version: 'org.springdoc:springdoc-openapi-ui:1.4.6'