Open ludovicianul opened 1 month ago
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 title: ''
at all.
Is there more context here, @ludovicianul ?
@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 uniqueName
should ensure that multiple empty titles won't cause conflicts, even if they're not pretty. This is one of those messy things, empty titles aren't great and should likely never be produced from the start.
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: