use of io.swagger.models.parameters.QueryParameter in project swagger-parser by swagger-api.
the class SwaggerParserTest method testIssue146.
@Test
public void testIssue146() {
SwaggerParser parser = new SwaggerParser();
final Swagger swagger = parser.read("src/test/resources/issue_146.yaml");
assertNotNull(swagger);
QueryParameter p = ((QueryParameter) swagger.getPaths().get("/checker").getGet().getParameters().get(0));
StringProperty pp = (StringProperty) p.getItems();
assertTrue("registration".equalsIgnoreCase(pp.getEnum().get(0)));
}
use of io.swagger.models.parameters.QueryParameter in project swagger-parser by swagger-api.
the class SwaggerResolverTest method testOperationParameterRemoteRefs.
@Test(description = "resolve operation parameter remote refs")
public void testOperationParameterRemoteRefs() {
final Swagger swagger = new Swagger();
swagger.path("/fun", new Path().get(new Operation().parameter(new RefParameter("#/parameters/SampleParameter"))));
swagger.parameter("SampleParameter", new QueryParameter().name("skip").property(new IntegerProperty()));
final Swagger resolved = new SwaggerResolver(swagger, null).resolve();
final List<Parameter> params = swagger.getPaths().get("/fun").getGet().getParameters();
assertEquals(params.size(), 1);
final QueryParameter param = (QueryParameter) params.get(0);
assertEquals(param.getName(), "skip");
}
use of io.swagger.models.parameters.QueryParameter in project swagger-parser by swagger-api.
the class SwaggerResolverTest method testSharedPathParametersTest.
@Test(description = "resolve shared path parameters")
public void testSharedPathParametersTest() {
final Swagger swagger = new Swagger();
Operation operation = new Operation().response(200, new Response().description("ok!"));
Path path = new Path().get(operation);
path.addParameter(new QueryParameter().name("username").property(new StringProperty()));
swagger.path("/fun", path);
final Swagger resolved = new SwaggerResolver(swagger, null).resolve();
assertNull(resolved.getPaths().get("/fun").getParameters());
assertTrue(resolved.getPaths().get("/fun").getGet().getParameters().size() == 1);
}
use of io.swagger.models.parameters.QueryParameter in project swagger-parser by swagger-api.
the class SwaggerDeserializerTest method testArrayQueryParam.
@Test
public void testArrayQueryParam() throws Exception {
String json = "{\n" + " \"swagger\": \"2.0\",\n" + " \"paths\": {\n" + " \"/pet/findByStatus\": {\n" + " \"get\": {\n" + " \"parameters\": [\n" + " {\n" + " \"name\": \"status\",\n" + " \"in\": \"query\",\n" + " \"description\": \"Status values that need to be considered for filter\",\n" + " \"required\": false,\n" + " \"type\": \"array\",\n" + " \"items\": {\n" + " \"type\": \"string\"\n" + " },\n" + " \"collectionFormat\": \"pipes\",\n" + " \"default\": \"available\"\n" + " }\n" + " ],\n" + " \"responses\": {\n" + " \"200\": {\n" + " \"description\": \"successful operation\",\n" + " \"schema\": {\n" + " \"$ref\": \"#/definitions/PetArray\"\n" + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}";
SwaggerParser parser = new SwaggerParser();
SwaggerDeserializationResult result = parser.readWithInfo(json);
Swagger swagger = result.getSwagger();
Parameter param = swagger.getPath("/pet/findByStatus").getGet().getParameters().get(0);
assertTrue(param instanceof QueryParameter);
QueryParameter qp = (QueryParameter) param;
Property p = qp.getItems();
assertEquals(qp.getType(), "array");
assertTrue(p instanceof StringProperty);
}
use of io.swagger.models.parameters.QueryParameter in project swagger-parser by swagger-api.
the class SwaggerDeserializerTest method testIssue343Parameter.
@Test
public void testIssue343Parameter() {
String yaml = "swagger: '2.0'\n" + "info:\n" + " description: 'bleh'\n" + " version: '2.0.0'\n" + " title: 'Test'\n" + "paths:\n" + " /foo:\n" + " post:\n" + " parameters:\n" + " - in: query\n" + " name: skip\n" + " type: integer\n" + " format: int32\n" + " multipleOf: 3\n" + " - in: body\n" + " name: body\n" + " required: true\n" + " schema:\n" + " type: object\n" + " additionalProperties:\n" + " type: string\n" + " responses:\n" + " 200:\n" + " description: 'OK'\n" + "definitions:\n" + " Fun:\n" + " properties:\n" + " id:\n" + " type: integer\n" + " format: int32\n" + " multipleOf: 5\n" + " mySet:\n" + " type: array\n" + " uniqueItems: true\n" + " items:\n" + " type: string";
SwaggerParser parser = new SwaggerParser();
SwaggerDeserializationResult result = parser.readWithInfo(yaml);
Swagger swagger = result.getSwagger();
QueryParameter qp = (QueryParameter) swagger.getPath("/foo").getPost().getParameters().get(0);
assertEquals(qp.getMultipleOf(), 3.0);
BodyParameter bp = (BodyParameter) swagger.getPath("/foo").getPost().getParameters().get(1);
ModelImpl schema = (ModelImpl) bp.getSchema();
assertTrue(schema.getAdditionalProperties() != null);
IntegerProperty id = (IntegerProperty) swagger.getDefinitions().get("Fun").getProperties().get("id");
assertEquals(id.getMultipleOf(), new BigDecimal("5"));
ArrayProperty ap = (ArrayProperty) swagger.getDefinitions().get("Fun").getProperties().get("mySet");
assertTrue(ap.getUniqueItems());
}
Aggregations