Skip to content

Commit 0d0d2e3

Browse files
damiankaplonspaewaostrowska
authored andcommitted
Create a failing test presenting open api 3.1 - enum property schema enumAsRef error
1 parent 46decb3 commit 0d0d2e3

File tree

1 file changed

+28
-0
lines changed
  • modules/swagger-core/src/test/java/io/swagger/v3/core/resolving

1 file changed

+28
-0
lines changed

modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/EnumTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@ public void testEnumGenerics() {
5656
assertNotNull(model.getProperties().get("type"));
5757
}
5858

59+
@Test
60+
public void testEnumPropertyWithSchemaAnnotation() {
61+
final ModelResolver modelResolver = new ModelResolver(mapper()).openapi31(true);
62+
final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
63+
64+
final Schema model = context.resolve(new AnnotatedType().type(ClassWithEnumAsRefProperty.class));
65+
assertNotNull(model);
66+
assertEquals(model.getName(), "ClassWithEnumAsRefProperty");
67+
assertTrue(model.getProperties().containsKey("enumWithSchemaProperty"));
68+
final Schema enumPropertySchema = (Schema) model.getProperties().get("enumWithSchemaProperty");
69+
assertNotNull(enumPropertySchema.get$ref());
70+
}
71+
72+
public static class ClassWithEnumAsRefProperty {
73+
74+
@io.swagger.v3.oas.annotations.media.Schema(enumAsRef = true)
75+
public final EnumWithSchemaProperty enumWithSchemaProperty;
76+
77+
public ClassWithEnumAsRefProperty(EnumWithSchemaProperty enumWithSchemaProperty) {
78+
this.enumWithSchemaProperty = enumWithSchemaProperty;
79+
}
80+
81+
public enum EnumWithSchemaProperty {
82+
VALUE1,
83+
VALUE2
84+
}
85+
}
86+
5987
public enum Currency {
6088
USA, CANADA
6189
}

0 commit comments

Comments
 (0)