use of io.swagger.v3.oas.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterDeSerializationTest method deserializeQueryParameterWithStyle.
@Test(description = "it should deserialize a QueryParameter with style")
public void deserializeQueryParameterWithStyle() throws IOException {
final String json = "{\"in\":\"query\",\"style\":\"form\",\"required\":false,\"schema\":{\"type\":\"string\"}}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.v3.oas.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterDeSerializationTest method deserializeArrayQueryParameter.
@Test(description = "it should deserialize a QueryParameter with array")
public void deserializeArrayQueryParameter() throws IOException {
final String json = "{" + " \"in\":\"query\"," + " \"required\":false," + " \"schema\":{" + " \"type\":\"array\"," + " \"items\":{" + " \"type\":\"string\"" + " }" + " }" + "}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.v3.oas.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class SwaggerSerializerTest method writeSpecWithParameterReferences.
@Test(description = "it should write a spec with parameter references")
public void writeSpecWithParameterReferences() throws IOException {
final Schema personModel = ModelConverters.getInstance().read(Person.class).get("Person");
final Info info = new Info().version("1.0.0").title("Swagger Petstore");
final Contact contact = new Contact().name("Swagger API Team").email("foo@bar.baz").url("http://swagger.io");
info.setContact(contact);
final OpenAPI swagger = new OpenAPI().info(info).addServersItem(new Server().url("http://petstore.swagger.io")).schema("Person", personModel);
final QueryParameter parameter = (QueryParameter) new QueryParameter().name("id").description("a common get parameter").schema(new IntegerSchema());
final Operation get = new Operation().summary("finds pets in the system").description("a longer description").operationId("get pet by id").addParametersItem(new Parameter().$ref("#/parameters/Foo"));
swagger.components(new Components().addParameters("Foo", parameter)).path("/pets", new PathItem().get(get));
final String swaggerJson = Json.mapper().writeValueAsString(swagger);
final OpenAPI rebuilt = Json.mapper().readValue(swaggerJson, OpenAPI.class);
assertEquals(Json.pretty(rebuilt), Json.pretty(swagger));
}
use of io.swagger.v3.oas.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method testBooleanValue.
@Test(description = "should serialize boolean value")
public void testBooleanValue() {
final QueryParameter param = (QueryParameter) new QueryParameter().required(false);
Schema schema = new Schema().type("boolean");
schema.setDefault("false");
param.setSchema(schema);
final String json = "{" + " \"in\":\"query\"," + " \"required\":false," + " \"schema\":{" + " \"type\":\"boolean\"," + " \"default\":\"false\"" + " }" + "}";
SerializationMatchers.assertEqualsToJson(param, json);
}
use of io.swagger.v3.oas.models.parameters.QueryParameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method testFloatValue.
@Test(description = "should serialize float value")
public void testFloatValue() {
final QueryParameter param = new QueryParameter();
param.setSchema(new NumberSchema()._default(new BigDecimal("12.34")).format("float"));
final String json = "{\"in\":\"query\",\"schema\":{\"type\":\"number\",\"format\":\"float\",\"default\":12.34}}";
SerializationMatchers.assertEqualsToJson(param, json);
}
Aggregations