Amartus / yang2swagger

Yang to swagger generator
Eclipse Public License 1.0
32 stars 21 forks source link

Replace getSchema() with getResponseSchema() in SwaggerRefHelper #61

Closed scottwn closed 1 year ago

scottwn commented 1 year ago

This PR fixes a bug in SwaggerRefHelper.

When PayloadWrapperProcessor creates a "wrapped" definition, it sets it in the response property using setResponseSchema.

https://github.com/bartoszm/yang2swagger/blob/4f513295e28612df4672b3ddb9ef8bc2456654b4/swagger-generator/src/main/java/com/mrv/yangtools/codegen/impl/postprocessor/PayloadWrapperProcessor.java#L63-L66

SwaggerRefHelper then attempts to retrieve the reference using the deprecated getSchema().

https://github.com/bartoszm/yang2swagger/blob/4f513295e28612df4672b3ddb9ef8bc2456654b4/swagger-generator/src/main/java/com/mrv/yangtools/codegen/impl/postprocessor/SwaggerRefHelper.java#L91

This causes yang2swagger to miss some references, and remove models that are in fact referenced in the generated swagger.

I am proposing a change to replace getSchema() with the updated getResponseSchema() to solve this problem.

scottwn commented 1 year ago

@bartoszm can I get a review on this?

bartoszm commented 1 year ago

Thank you @scottwn for the contribution.