Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI 3.1 breaks custom ModelResolver #4432

Closed
papegaaij opened this issue Jun 23, 2023 · 2 comments
Closed

OpenAPI 3.1 breaks custom ModelResolver #4432

papegaaij opened this issue Jun 23, 2023 · 2 comments

Comments

@papegaaij
Copy link

When OpenAPI 3.1 is enabled, ParameterProcessor no longer uses the global singleton ModelConverters.getInstance(), but instead creates a new instance. This new instance obviously does not know about any custom model resolvers. The faulty code is here: https://github.com/swagger-api/swagger-core/blob/v2.2.12/modules/swagger-core/src/main/java/io/swagger/v3/core/util/ParameterProcessor.java#L70-L74 . The same problem exists in AnnotationsUtils.resolveSchemaFromType. This breaks our OpenAPI generation completely if we try to switch to 3.1, because types are resolved with totally incorrect names.

Rather than creating a new ModelConverters, OpenAPI 3.1 should be enabled on the default implementation. Using version 3.1 is a global setting anyway. The ModelConverters class should not have any public constructor, as it is only meant to be used as a singleton. Keeping the constructor private should prevent such errors in the future.

@frantuma
Copy link
Member

@papegaaij thanks for reporting and investigating this. You are right about the issue, this should be however solved by #4433 (just merged and released). Some more tweaks will follow but this should solve your immediate problem. Please reopen ticket if this is not the case.

As for the public constructor, PR above chooses another path, mainly to maintain API backward compatibility, even if reason of having public constructors is purely historical.

@papegaaij
Copy link
Author

@frantuma this does indeed resolve the issue, thanks! Perhaps you can make the ModelConverters.getInstance method without the boolean deprecated? I still had some references to this method in our code, which caused issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants