swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
773 stars 525 forks source link

$ref to external component are not add as shared component for open API 3.1 but recreated for each usage #2079

Open pkernevez opened 2 months ago

pkernevez commented 2 months ago

As describe in this issue https://github.com/OpenAPITools/openapi-generator/issues/18361 I have a difference in the parser behavior.

With 3.0 schema, the reference to an external component is parse with it's own structure. It allow to have a common implementation for things like mapping (an exemple with a comme Amount component that reproduce the issue is available here: https://github.com/pkernevez/pb-openapi).

With 3.1 schema the parsing don't create common components, there are new classes (with the attributes) for each usage. It's not possible to have shared Dto anymore nor share mapping implementation.

It try with and without setResolveFully (as I saw https://github.com/swagger-api/swagger-parser/issues/1950 that seems to be closed to this issue, but isn't). Output without setResolveFully image

Output with setResolveFully

image