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
If ModelResolver.enumsAsRef is set to true and model contains property with java.time.DayOfWeek enum, then generation of OpenAPI specification for such a model will result in the following exception:
java.lang.NullPointerException: null
at java.base/java.util.Objects.requireNonNull(Objects.java:208)
at java.base/java.util.TreeMap.put(TreeMap.java:809)
at java.base/java.util.TreeMap.put(TreeMap.java:534)
at io.swagger.v3.core.converter.ModelConverterContextImpl.defineModel(ModelConverterContextImpl.java:60)
at io.swagger.v3.core.jackson.ModelResolver.resolve(ModelResolver.java:350)
at org.springdoc.core.converters.AdditionalModelsConverter.resolve(AdditionalModelsConverter.java:155)
at org.springdoc.core.converters.FileSupportConverter.resolve(FileSupportConverter.java:69)
at org.springdoc.core.converters.ResponseSupportConverter.resolve(ResponseSupportConverter.java:79)
at ...
I believe the problem is that ModelResolver.resolve( ) checks if type is not system type (using ReflectionUtils.isSystemType(type)) and if so, default value of property schema name is not inferred from its type name.
Proposed solution is to skip system type check for enum types.
Tested with io.swagger.core.v3:swagger-core-jakarta:2.2.8
The text was updated successfully, but these errors were encountered:
mdjimy
changed the title
Schema generation for system enums fails if enumsAsRef is enabled
Resolving Schema for system enums fails if enumsAsRef is enabled
Feb 17, 2023
mdjimy
pushed a commit
to mdjimy/swagger-core
that referenced
this issue
Feb 17, 2023
If
ModelResolver.enumsAsRef
is set totrue
and model contains property withjava.time.DayOfWeek
enum, then generation of OpenAPI specification for such a model will result in the following exception:I believe the problem is that
ModelResolver.resolve( )
checks if type is not system type (usingReflectionUtils.isSystemType(type)
) and if so, default value of property schemaname
is not inferred from its type name.Proposed solution is to skip system type check for enum types.
Here you can find gist with minimal code example to reproduce the problem:
https://gist.github.com/mdjimy/2a08b1f9f0eb26485f2794c50df7dd35
Tested with
io.swagger.core.v3:swagger-core-jakarta:2.2.8
The text was updated successfully, but these errors were encountered: