Search in sources :

Example 61 with AnnotatedType

use of io.swagger.v3.core.converter.AnnotatedType in project swagger-core by swagger-api.

the class EnumPropertyTest method testEnumRefProperty.

@Test(description = "it should read a model with an enum property as a reference")
public void testEnumRefProperty() {
    Schema schema = context.resolve(new AnnotatedType(ModelWithEnumRefProperty.class));
    final Map<String, Schema> models = context.getDefinedModels();
    final String yaml = "ModelWithEnumRefProperty:\n" + "  type: object\n" + "  properties:\n" + "    a:\n" + "      $ref: '#/components/schemas/TestEnum'\n" + "    b:\n" + "      $ref: '#/components/schemas/TestEnum'\n" + "    c:\n" + "      $ref: '#/components/schemas/TestSecondEnum'\n" + "    d:\n" + "      type: string\n" + "      enum:\n" + "      - A_PRIVATE\n" + "      - A_PUBLIC\n" + "      - A_SYSTEM\n" + "      - A_INVITE_ONLY\n" + "TestEnum:\n" + "  type: string\n" + "  enum:\n" + "  - PRIVATE\n" + "  - PUBLIC\n" + "  - SYSTEM\n" + "  - INVITE_ONLY\n" + "TestSecondEnum:\n" + "  type: string\n" + "  enum:\n" + "  - A_PRIVATE\n" + "  - A_PUBLIC\n" + "  - A_SYSTEM\n" + "  - A_INVITE_ONLY\n";
    SerializationMatchers.assertEqualsToYaml(models, yaml);
}
Also used : AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) ModelWithEnumRefProperty(io.swagger.v3.core.oas.models.ModelWithEnumRefProperty) StringSchema(io.swagger.v3.oas.models.media.StringSchema) Schema(io.swagger.v3.oas.models.media.Schema) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Aggregations

Schema (io.swagger.v3.oas.models.media.Schema)60 AnnotatedType (io.swagger.v3.core.converter.AnnotatedType)57 Test (org.testng.annotations.Test)47 ModelConverterContextImpl (io.swagger.v3.core.converter.ModelConverterContextImpl)25 ModelResolver (io.swagger.v3.core.jackson.ModelResolver)21 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)14 ComposedSchema (io.swagger.v3.oas.models.media.ComposedSchema)13 AfterTest (org.testng.annotations.AfterTest)13 StringSchema (io.swagger.v3.oas.models.media.StringSchema)11 ModelConverter (io.swagger.v3.core.converter.ModelConverter)6 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)6 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)6 Annotation (java.lang.annotation.Annotation)6 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)5 JavaType (com.fasterxml.jackson.databind.JavaType)4 MapSchema (io.swagger.v3.oas.models.media.MapSchema)4 NumberSchema (io.swagger.v3.oas.models.media.NumberSchema)4 UUIDSchema (io.swagger.v3.oas.models.media.UUIDSchema)4 ArrayList (java.util.ArrayList)4