use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class SpecFilterTest method filterAwaySecretParameters.
@Test(description = "it should filter away secret parameters")
public void filterAwaySecretParameters() throws IOException {
final Swagger swagger = getSwagger("specFiles/sampleSpec.json");
final RemoveInternalParamsFilter filter = new RemoveInternalParamsFilter();
final Swagger filtered = new SpecFilter().filter(swagger, filter, null, null, null);
if (filtered.getPaths() != null) {
for (Map.Entry<String, Path> entry : filtered.getPaths().entrySet()) {
final Operation get = entry.getValue().getGet();
for (Parameter param : get.getParameters()) {
final String description = param.getDescription();
assertNotNull(description);
assertFalse(description.startsWith("secret"));
}
}
} else {
fail("paths should not be null");
}
}
use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method deserializeRefBodyParameter.
@Test(description = "it should deserialize a ref BodyParameter")
public void deserializeRefBodyParameter() throws IOException {
final String json = "{\"in\":\"body\",\"required\":false,\"schema\":{\"$ref\":\"#/definitions/Cat\"}}";
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 deserializeArrayQueryParameter.
@Test(description = "it should deserialize a QueryParameter with array")
public void deserializeArrayQueryParameter() throws IOException {
final String json = "{" + " \"in\":\"query\"," + " \"required\":false," + " \"type\":\"array\"," + " \"items\":{" + " \"type\":\"string\"" + " }," + " \"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 deserializeNumberEnumPathParameter.
@Test(description = "it should deserialize a number path parameter with enum")
public void deserializeNumberEnumPathParameter() throws IOException {
final String json = "{" + " \"in\":\"path\"," + " \"required\":true," + " \"items\":{" + " \"type\":\"integer\"" + " }," + " \"enum\":[1,2,3]" + "}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
assertEquals(((PathParameter) p).getEnumValue(), Arrays.asList(1, 2, 3));
}
use of io.swagger.models.parameters.Parameter in project swagger-core by swagger-api.
the class ParameterSerializationTest method deserializeBodyParameter.
@Test(description = "it should deserialize a BodyParameter")
public void deserializeBodyParameter() throws IOException {
final String json = "{" + " \"in\":\"body\"," + " \"required\":false," + " \"schema\":{" + " \"properties\":{" + " \"name\":{" + " \"type\":\"string\"" + " }" + " }" + " }" + "}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
}
Aggregations