Search in sources :

Example 16 with QueryParameter

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

the class ParameterSerializationTest method testIncorrectLong.

@Test(description = "should not serialize incorrect long value")
public void testIncorrectLong() {
    final QueryParameter param = (QueryParameter) new QueryParameter().required(false);
    Schema schema = new IntegerSchema().format("int64");
    schema.setDefault("test");
    param.setSchema(schema);
    final String json = "{" + "   \"in\":\"query\"," + "   \"required\":false," + "   \"schema\":{" + "      \"type\":\"integer\"," + "       \"format\":\"int64\"" + "   }" + "}";
    SerializationMatchers.assertEqualsToJson(param, json);
}
Also used : QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) IntegerSchema(io.swagger.v3.oas.models.media.IntegerSchema) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) StringSchema(io.swagger.v3.oas.models.media.StringSchema) NumberSchema(io.swagger.v3.oas.models.media.NumberSchema) Schema(io.swagger.v3.oas.models.media.Schema) IntegerSchema(io.swagger.v3.oas.models.media.IntegerSchema) Test(org.testng.annotations.Test)

Example 17 with QueryParameter

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

the class ParameterSerializationTest method testReadOnlyParameter.

@Test(description = "should mark a parameter as readOnly")
public void testReadOnlyParameter() throws Exception {
    final QueryParameter qp = new QueryParameter();
    qp.setSchema(new StringSchema().readOnly(true));
    final String json = "{" + "   \"in\":\"query\"," + "   \"schema\":{" + "      \"type\":\"string\"," + "      \"readOnly\":true" + "   }" + "}";
    SerializationMatchers.assertEqualsToJson(qp, json);
}
Also used : QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) StringSchema(io.swagger.v3.oas.models.media.StringSchema) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)17 QueryParameter (io.swagger.v3.oas.models.parameters.QueryParameter)14 StringSchema (io.swagger.v3.oas.models.media.StringSchema)11 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)8 NumberSchema (io.swagger.v3.oas.models.media.NumberSchema)8 Schema (io.swagger.v3.oas.models.media.Schema)8 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)7 Parameter (io.swagger.v3.oas.models.parameters.Parameter)7 HeaderParameter (io.swagger.v3.oas.models.parameters.HeaderParameter)3 PathParameter (io.swagger.v3.oas.models.parameters.PathParameter)3 BigDecimal (java.math.BigDecimal)3 Components (io.swagger.v3.oas.models.Components)2 OpenAPI (io.swagger.v3.oas.models.OpenAPI)2 Operation (io.swagger.v3.oas.models.Operation)2 PathItem (io.swagger.v3.oas.models.PathItem)2 Contact (io.swagger.v3.oas.models.info.Contact)2 Info (io.swagger.v3.oas.models.info.Info)2 Person (io.swagger.v3.core.oas.models.Person)1 ExternalDocumentation (io.swagger.v3.oas.models.ExternalDocumentation)1 Paths (io.swagger.v3.oas.models.Paths)1