Springfox: @ApiResponse response parameter not used in 3.0.0

Created on 17 Aug 2020  ·  6Comments  ·  Source: springfox/springfox

Starting with 3.0.0 (in 2.9.2 it worked properly)

@ApiResponse(code = 404, message = "Not Found", response = CustomError::class)

The 404 - Not Found is in the documentation, but the defined response (CustomError in example) not shown in the generated documentation (response sample and model)

bug

Most helpful comment

To workaround it for now, add: springfox.documentation.swagger.use-model-v3=false

The prescribed workaround doesn't seem to work for ResponseEntity<?> return types. I'm not sure if that's a separate issue or if it's part and parcel to this bug.

All 6 comments

@varjasz do you find any solution?

@varjasz do you find any solution?

No, but I wasn't looking for it.

Thanks for reporting @varjasz

Same issue here.
After some debugging, root cause should be: https://github.com/springfox/springfox/blob/07a4c86d70b791f21c2d2f656a863920b8c883c7/springfox-swagger2/src/main/java/springfox/documentation/swagger2/mappers/ServiceModelToSwagger2Mapper.java#L117

Springfox 3.0 uses v3 models by default, but source.getResponses() gives wrong type. To workaround it for now, add:
springfox.documentation.swagger.use-model-v3=false in your application.properties.

To workaround it for now, add: springfox.documentation.swagger.use-model-v3=false

The prescribed workaround doesn't seem to work for ResponseEntity<?> return types. I'm not sure if that's a separate issue or if it's part and parcel to this bug.

I can confirm the fix with springfox.documentation.swagger.use-model-v3=false for doc type DocumentationType.SWAGGER_2.

On the other hand, shouldn't it work out of the box with doc type DocumentationType.OAS_30? I tried it both with and without the app.prop setting but it behaves the same as the initial issue by not showing up at all.

Was this page helpful?
0 / 5 - 0 ratings