Search in sources :

Example 11 with NumberSchema

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

the class ParameterSerializationTest method testDoubleValue.

@Test(description = "should serialize double value")
public void testDoubleValue() {
    final QueryParameter param = new QueryParameter();
    param.setSchema(new NumberSchema()._default(new BigDecimal("12.34")).format("double"));
    final String json = "{\"in\":\"query\",\"schema\":{\"type\":\"number\",\"format\":\"double\",\"default\":12.34}}";
    SerializationMatchers.assertEqualsToJson(param, json);
}
Also used : QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) NumberSchema(io.swagger.v3.oas.models.media.NumberSchema) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 12 with NumberSchema

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

the class PropertySerializationTest method serializeFloatProperty.

@Test(description = "it should serialize a FloatProperty")
public void serializeFloatProperty() throws IOException {
    final NumberSchema p = new NumberSchema()._default(new BigDecimal("1.2"));
    p.format("float");
    final String json = "{\"type\":\"number\",\"format\":\"float\",\"default\":1.2}";
    assertEquals(m.writeValueAsString(p), json);
}
Also used : NumberSchema(io.swagger.v3.oas.models.media.NumberSchema) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Aggregations

NumberSchema (io.swagger.v3.oas.models.media.NumberSchema)11 StringSchema (io.swagger.v3.oas.models.media.StringSchema)8 Test (org.testng.annotations.Test)8 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)7 Schema (io.swagger.v3.oas.models.media.Schema)7 BigDecimal (java.math.BigDecimal)7 ComposedSchema (io.swagger.v3.oas.models.media.ComposedSchema)4 DateSchema (io.swagger.v3.oas.models.media.DateSchema)4 DateTimeSchema (io.swagger.v3.oas.models.media.DateTimeSchema)4 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)4 MapSchema (io.swagger.v3.oas.models.media.MapSchema)4 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)4 HashMap (java.util.HashMap)4 ResolvedType (com.github.javaparser.resolution.types.ResolvedType)3 BooleanSchema (io.swagger.v3.oas.models.media.BooleanSchema)3 QueryParameter (io.swagger.v3.oas.models.parameters.QueryParameter)3 Test (org.junit.Test)3 Type (com.github.javaparser.ast.type.Type)1 ResolvedArrayType (com.github.javaparser.resolution.types.ResolvedArrayType)1 ResolvedPrimitiveType (com.github.javaparser.resolution.types.ResolvedPrimitiveType)1