-
Notifications
You must be signed in to change notification settings - Fork 531
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
Inline schemas get empty model name when title is empty #2118
Comments
…e schemas are gettting proper model name
This looks like expected behaviour. An empty string, is still a string. So it should prefer that. The workaround would be to not provide a @frantuma what happens when we serialize this back out, does that work as expected? |
It's still a string, but if all objects will have empty title, that will be a conflict. They will just override each other's schema. I suspect there might be frameworks out there that generate the OpenAPI file with empty title instead of null and setting empty title is not deliberate. My view is that null and empty should be treated the same in this particular case. |
@ludovicianul the However, the goal of creating the names of schemas is to be helpful, not pure. And adding an empty string test can help things. Will try get the PR merged when we get a chance, thank you :) |
Description
When an inline schema has empty title, the resulted model has an empty name causing schema to not properly be resolved.
swagger-parser version
Version 2.1.22
OpenAPI declaration file content or url
Generation Details
Use the following code:
You can check the
openAPI.getComponents.getSchemas()
that it contains an empty model with an empty title and those 3 properties.Steps to reproduce
See above
Suggest a fix
The issue seems to be this code from the
io.swagger.v3.parser.util.InlineModelResolver
class:The fix is to test for empty strings also:
The text was updated successfully, but these errors were encountered: