swagger-api / swagger-api/swagger-parser
$ref to external component are not add as shared component for open API 3.1 but recreated for each usage
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
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
Output with setResolveFully
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer linked in the issue at github.com/pkernevez/pb-openapi and compare parsing of the external component under OpenAPI 3.0 and 3.1, both with and without setResolveFully. Trace how external $ref components are represented for repeated usages. Done means OpenAPI 3.1 preserves a shared component structure instead of creating new classes for each usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100