use of io.swagger.v3.oas.models.media.BooleanSchema in project swagger-core by swagger-api.
the class ModelPropertyTest method testIssue1743.
@Test
public void testIssue1743() {
final Map<String, Schema> models = ModelConverters.getInstance().readAll(ModelWithBooleanProperty.class);
final Schema model = models.get("ModelWithBooleanProperty");
assertNotNull(model);
BooleanSchema bp = (BooleanSchema) model.getProperties().get("isGreat");
assertTrue(bp.getEnum().size() == 1);
assertEquals(bp.getEnum().get(0), Boolean.TRUE);
IntegerSchema is = (IntegerSchema) model.getProperties().get("intValue");
assertTrue(is.getEnum().size() == 2);
assertEquals(is.getEnum().get(0), new Integer(1));
assertEquals(is.getEnum().get(1), new Integer(2));
}
use of io.swagger.v3.oas.models.media.BooleanSchema in project swagger-core by swagger-api.
the class PropertySerializationTest method deserializeBooleanSchema.
@Test(description = "it should deserialize a BooleanSchema")
public void deserializeBooleanSchema() throws IOException {
final String json = "{\"type\":\"boolean\",\"default\":false}";
final Schema p = m.readValue(json, Schema.class);
assertEquals(p.getType(), "boolean");
assertNull(p.getFormat());
assertEquals(p.getClass(), BooleanSchema.class);
assertEquals(((BooleanSchema) p).getDefault(), Boolean.FALSE);
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.v3.oas.models.media.BooleanSchema in project swagger-core by swagger-api.
the class PropertySerializationTest method serializeBooleanSchema.
@Test(description = "it should serialize a BooleanSchema")
public void serializeBooleanSchema() throws IOException {
final BooleanSchema p = new BooleanSchema()._default(true);
final String json = "{\"type\":\"boolean\",\"default\":true}";
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.v3.oas.models.media.BooleanSchema in project flow by vaadin.
the class SchemaResolverTest method should_ReturnNullableBoolean_When_GivenTypeIsABoxedBoolean.
@Test
public void should_ReturnNullableBoolean_When_GivenTypeIsABoxedBoolean() {
ResolvedType resolvedType = mockReferencedTypeOf(Boolean.class);
Map<String, GeneratorType> usedTypes = new HashMap<>();
SchemaResolver schemaResolver = new SchemaResolver(new GeneratorType(resolvedType), usedTypes);
Schema schema = schemaResolver.resolve();
Assert.assertTrue(schema instanceof BooleanSchema);
Assert.assertTrue(schema.getNullable());
Assert.assertTrue(usedTypes.isEmpty());
}
use of io.swagger.v3.oas.models.media.BooleanSchema in project flow by vaadin.
the class SchemaResolverTest method should_ReturnNotNullableBoolean_When_GivenTypeIsAPrimitiveBoolean.
@Test
public void should_ReturnNotNullableBoolean_When_GivenTypeIsAPrimitiveBoolean() {
ResolvedType resolvedType = mockPrimitiveTypeOf(ResolvedPrimitiveType.BOOLEAN);
Map<String, GeneratorType> usedTypes = new HashMap<>();
SchemaResolver schemaResolver = new SchemaResolver(new GeneratorType(resolvedType), usedTypes);
Schema schema = schemaResolver.resolve();
Assert.assertTrue(schema instanceof BooleanSchema);
Assert.assertNull(schema.getNullable());
Assert.assertTrue(usedTypes.isEmpty());
}
Aggregations