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
Introduce a method that can be overriden, or another mechanism, to allow for model name customization. An example would be to have a suffix "Enum" for all enum models resolved as ref.
Doing this with a custom model resolver doesn't work.
publicclassEnumModelConverterimplementsModelConverter {
@OverridepublicSchema<?> resolve(AnnotatedTypetype, ModelConverterContextcontext, Iterator<ModelConverter> chain) {
if (chain.hasNext()) {
if (type.getType() instanceofJavaTypejavaType) {
if (javaType.isEnumType()) {
if (!javaType.getRawClass().getSimpleName().endsWith("Enum")) {
type.setName(javaType.getRawClass().getSimpleName() + "Enum");
}
}
} elseif (type.getType() instanceofClass<?> clazz) {
if (clazz.isEnum()) {
if (!clazz.getSimpleName().endsWith("Enum")) {
type.setName(clazz.getSimpleName() + "Enum");
}
}
}
returnchain.next().resolve(type, context, chain);
}
returnnull;
}
}
While this seems to work, it fails as soon as you have an enum with a custom name in its Schema annotation.
@Schema(name = "SomeClassStatus")
publicenumStatus {
ONE, TWO
}
Introduce a method that can be overriden, or another mechanism, to allow for model name customization. An example would be to have a suffix "Enum" for all enum models resolved as ref.
Doing this with a custom model resolver doesn't work.
While this seems to work, it fails as soon as you have an enum with a custom
name
in itsSchema
annotation.Proposal:
Add a protected method after
swagger-core/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java
Line 213 in 3c7b61f
The text was updated successfully, but these errors were encountered: