Search in sources :

Example 1 with Model1979

use of io.swagger.v3.core.oas.models.Model1979 in project swagger-core by swagger-api.

the class EnumPropertyTest method testEnumRefPropertyGlobalNotAffectingNonEnums.

@Test(description = "it should not affect non-enum models when the enumsAsRef property is enabled globally")
public void testEnumRefPropertyGlobalNotAffectingNonEnums() {
    ModelResolver.enumsAsRef = true;
    Schema schema = context.resolve(new AnnotatedType(Model1979.class));
    final Map<String, Schema> models = context.getDefinedModels();
    final String yaml = "Model1979:\n" + "  type: object\n" + "  properties:\n" + "    id:\n" + "      type: string\n" + "      nullable: true";
    SerializationMatchers.assertEqualsToYaml(models, yaml);
    ModelResolver.enumsAsRef = false;
}
Also used : AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) StringSchema(io.swagger.v3.oas.models.media.StringSchema) Schema(io.swagger.v3.oas.models.media.Schema) Model1979(io.swagger.v3.core.oas.models.Model1979) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest)

Example 2 with Model1979

use of io.swagger.v3.core.oas.models.Model1979 in project swagger-core by swagger-api.

the class ModelPropertyTest method modelAllowEmptyTest.

@Test
public void modelAllowEmptyTest() {
    final Map<String, Schema> models = ModelConverters.getInstance().readAll(Model1979.class);
    Schema model = models.get("Model1979");
    assertTrue(((Schema) model.getProperties().get("id")).getNullable());
}
Also used : BooleanSchema(io.swagger.v3.oas.models.media.BooleanSchema) IntegerSchema(io.swagger.v3.oas.models.media.IntegerSchema) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) StringSchema(io.swagger.v3.oas.models.media.StringSchema) Schema(io.swagger.v3.oas.models.media.Schema) Test(org.testng.annotations.Test)

Aggregations

Schema (io.swagger.v3.oas.models.media.Schema)2 StringSchema (io.swagger.v3.oas.models.media.StringSchema)2 Test (org.testng.annotations.Test)2 AnnotatedType (io.swagger.v3.core.converter.AnnotatedType)1 Model1979 (io.swagger.v3.core.oas.models.Model1979)1 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)1 BooleanSchema (io.swagger.v3.oas.models.media.BooleanSchema)1 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)1 AfterTest (org.testng.annotations.AfterTest)1