use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class SwaggerJersey2JaxrsTest method scanClassAnfFieldLevelAnnotations.
@Test(description = "scan class level and field level annotations")
public void scanClassAnfFieldLevelAnnotations() {
final Swagger swagger = new Reader(new Swagger()).read(ResourceWithKnownInjections.class);
final List<Parameter> resourceParameters = swagger.getPaths().get("/resource/{id}").getGet().getParameters();
assertNotNull(resourceParameters);
assertEquals(resourceParameters.size(), 4);
assertEquals(getName(resourceParameters, 0), "fieldParam");
assertEquals(getName(resourceParameters, 1), "skip");
assertEquals(getName(resourceParameters, 2), "limit");
assertEquals(getName(resourceParameters, 3), "methodParam");
}
use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method deserializePathParameter.
@Test(description = "it should deserialize a PathParameter")
public void deserializePathParameter() throws IOException {
final String json = "{\"in\":\"query\",\"required\":true,\"type\":\"string\"}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
assertTrue(p.getRequired());
}
use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method deserializeIntegerArrayPathParameter.
@Test(description = "it should deserialize a PathParameter with integer array ")
public void deserializeIntegerArrayPathParameter() throws IOException {
final String json = "{" + " \"in\":\"path\"," + " \"required\":true," + " \"type\":\"array\"," + " \"items\":{" + " \"type\":\"integer\"," + " \"format\":\"int32\"" + " }," + " \"collectionFormat\":\"multi\"" + "}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
}
use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method deserializeEnumPathParameter.
@Test(description = "it should deserialize a path parameter with enum")
public void deserializeEnumPathParameter() throws IOException {
final String json = "{" + " \"in\":\"path\"," + " \"required\":true," + " \"items\":{" + " \"type\":\"string\"" + " }," + " \"enum\":[\"a\",\"b\",\"c\"]" + "}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
assertEquals(((PathParameter) p).getEnum(), Arrays.asList("a", "b", "c"));
}
use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method deserializeStringArrayPathParameter.
@Test(description = "it should deserialize a PathParameter with string array")
public void deserializeStringArrayPathParameter() throws IOException {
final String json = "{" + " \"in\":\"path\"," + " \"required\":true," + " \"type\":\"array\"," + " \"items\":{" + " \"type\":\"string\"" + " }," + " \"collectionFormat\":\"multi\"" + "}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
}
Aggregations