Search in sources :

Example 1 with ModelWithEnumRefProperty

use of io.swagger.v3.core.oas.models.ModelWithEnumRefProperty 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

AnnotatedType (io.swagger.v3.core.converter.AnnotatedType)1 ModelWithEnumRefProperty (io.swagger.v3.core.oas.models.ModelWithEnumRefProperty)1 Schema (io.swagger.v3.oas.models.media.Schema)1 StringSchema (io.swagger.v3.oas.models.media.StringSchema)1 AfterTest (org.testng.annotations.AfterTest)1 Test (org.testng.annotations.Test)1