Search in sources :

Example 11 with QueryParameter

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

the class ParameterSerializationTest method testAllowEmptyValueParameter.

@Test(description = "should mark a parameter as to allow empty value")
public void testAllowEmptyValueParameter() throws Exception {
    final Parameter qp = new QueryParameter().allowEmptyValue(true);
    final String json = "{\"in\":\"query\",\"allowEmptyValue\":true}";
    SerializationMatchers.assertEqualsToJson(qp, json);
}
Also used : QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) Parameter(io.swagger.v3.oas.models.parameters.Parameter) QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) HeaderParameter(io.swagger.v3.oas.models.parameters.HeaderParameter) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) Test(org.testng.annotations.Test)

Example 12 with QueryParameter

use of io.swagger.v3.oas.models.parameters.QueryParameter 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 13 with QueryParameter

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

the class ParameterSerializationTest method serializeQueryParameter.

@Test(description = "it should serialize a QueryParameter")
public void serializeQueryParameter() {
    final Parameter p = new QueryParameter().schema(new StringSchema());
    final String json = "{\"in\":\"query\",\"schema\":{\"type\":\"string\"}}";
    SerializationMatchers.assertEqualsToJson(p, json);
}
Also used : QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) Parameter(io.swagger.v3.oas.models.parameters.Parameter) QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) HeaderParameter(io.swagger.v3.oas.models.parameters.HeaderParameter) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) StringSchema(io.swagger.v3.oas.models.media.StringSchema) Test(org.testng.annotations.Test)

Example 14 with QueryParameter

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

the class ParameterSerializationTest method serializeArrayQueryParameter.

@Test(description = "it should serialize a QueryParameter with array")
public void serializeArrayQueryParameter() {
    final Parameter p = new QueryParameter().schema(new ArraySchema().items(new StringSchema()));
    final String json = "{" + "   \"in\":\"query\"," + "   \"schema\":{" + "     \"type\":\"array\"," + "     \"items\":{" + "       \"type\":\"string\"" + "   }}" + "}";
    SerializationMatchers.assertEqualsToJson(p, json);
}
Also used : QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) Parameter(io.swagger.v3.oas.models.parameters.Parameter) QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) HeaderParameter(io.swagger.v3.oas.models.parameters.HeaderParameter) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) StringSchema(io.swagger.v3.oas.models.media.StringSchema) Test(org.testng.annotations.Test)

Example 15 with QueryParameter

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

the class ParameterSerializationTest method testIncorrectBoolean.

@Test(description = "should serialize incorrect boolean value as string")
public void testIncorrectBoolean() {
    final QueryParameter param = (QueryParameter) new QueryParameter().required(false);
    Schema schema = new Schema().type("boolean");
    schema.setDefault("test");
    param.setSchema(schema);
    final String json = "{" + "   \"in\":\"query\"," + "   \"required\":false," + "   \"schema\":{" + "      \"type\":\"boolean\"," + "       \"default\":\"test\"" + "   }" + "}";
    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) 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