Reputation: 181
I'm using springdoc-openapi library for auto generation and rendering of swagger-ui. I need to add default value for accept header. How to do this?
springfox allows to do this using defaultValue function of ParameterBuilder. Attaching the screenshot. I want to achieve the same without using springfox.
Upvotes: 0
Views: 3248
Reputation:
If you need to add global parameter in the Header to all your operations, you can use OperationCustomizer :
@Bean
public OperationCustomizer addCustomGlobalHeader() {
return (Operation operation, HandlerMethod handlerMethod) -> {
Parameter headerParameter = new Parameter().in(ParameterIn.HEADER.toString()).required(true).
schema(new StringSchema().
_default("application/json;api-verision=1.0")).name("Accept");
operation.addParametersItem(headerParameter);
return operation;
};
}
Upvotes: 3