You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the feature
I've put this as a feature request rather than a bug as it appears to be documented behaviour in the underlying Swagger implementation. Basically, if you create two classes with the same name, but in a different package, you only end up with one underlying model in the schema which means your API documentation is now wrong!
In other words, if I have an API for Thing1 and an API for Thing2 and I create a package structure like
Then any API documentation for thing2 will refer to the DTOs for Thing1 which isn't good...
Additional context
This is down to the fact that the swagger model generator, by default, just uses the class name - not the fully qualified name. This can be quite a pain if you want to have models called UpdateRequest or UpdateDTO or similar and keep the names consistent. Obviously, you could rename to Thing1UpdateRequest and Thing2UpdateRequest but there is are some alternative options discussed here
In there, you can provide a different value for the name which will be used in the OpenAPI schema but you have to manually check your codeback before you know whether you have any naming conflicts.
I'm currently looking into writing a custom TypeNameResolver. Implementing it in the OpenAPI plugin was easy (provide an option to set it in OpenAPIOptions, pass it to the JacksonModelConverterFactory and then on to the JacksonModelConverter) but I'm trying to work out how often it gets called so I can work out if there is a way of raising an error on duplicate model names
Describe the feature
I've put this as a feature request rather than a bug as it appears to be documented behaviour in the underlying Swagger implementation. Basically, if you create two classes with the same name, but in a different package, you only end up with one underlying model in the schema which means your API documentation is now wrong!
In other words, if I have an API for Thing1 and an API for Thing2 and I create a package structure like
Then any API documentation for thing2 will refer to the DTOs for Thing1 which isn't good...
Additional context
This is down to the fact that the swagger model generator, by default, just uses the class name - not the fully qualified name. This can be quite a pain if you want to have models called UpdateRequest or UpdateDTO or similar and keep the names consistent. Obviously, you could rename to Thing1UpdateRequest and Thing2UpdateRequest but there is are some alternative options discussed here
ministryofjustice/prison-api#273
springfox/springfox#182
and this thread (for .NET) suggests a solution by overriding the schemaID generation function in Swagger / OpenAPI
https://stackoverflow.com/questions/46071513/swagger-error-conflicting-schemaids-duplicate-schemaids-detected-for-types-a-a
The text was updated successfully, but these errors were encountered: