Reputation: 401
As described in the title - Swagger is not showing API Models and not ignoring default response codes
I have uploaded the source code to - https://bitbucket.org/vambits/inactiveaccounts/src/master/
git clone https://bitbucket.org/vambits/inactiveaccounts.git
I am not sure why the API Model objects: SimpleRequest
and SimpleResponse
are not showing up in the Swagger UI.
As you can see there are no "Models" at the End.
In the code, i have set .build()).useDefaultResponseMessages(false)
but still the default response codes are getting shown. How to fix this??
Note: The functionality of this application is irrelevant.
Swagger Docket Configuration is as below -
@Bean
public Docket swaggerApi()
{
return new Docket(DocumentationType.SWAGGER_2).protocols(Sets.newHashSet("http", "https"))
/*
* Make sure swagger doesn't auto-generate error responses that we won't be using (e.g. 401, 403)
*/
/*
* Since SpringFox doesn't support the @SwaggerDefinition, specify that metadata here
*/
.apiInfo(new ApiInfoBuilder().title("InactiveAccountsApplication Pricing").version("1")
.contact(new Contact("InactiveAccountsApplication Services", null, "[email protected]"))
.description(
"InactiveAccountsApplication returns the inactive accounts list")
.build())
.useDefaultResponseMessages(false)
.select()
.apis(RequestHandlerSelectors.basePackage(InactiveAccountsApplication.class.getPackage().getName()))
.paths(PathSelectors.any()).build();
}
Upvotes: 0
Views: 1356
Reputation: 1701
I would recommend to use springdoc instead of the springfox libraries, because they are pretty outdated.
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.8</version>
</dependency>
Here you can find the documentation including a migration guide
The models should be included out of the box then.
Regarding your second question:
The response codes shown in your screenshot aren't the default response messages. They are the responses that you described in your controller, so I don't understand what the problem is.
Upvotes: 1