use of io.swagger.models.parameters.QueryParameter in project swagger-parser by swagger-api.
the class QueryParameterConverterTest method convertStringArrayQueryParameter.
@Test
public void convertStringArrayQueryParameter() throws Exception {
io.swagger.models.apideclaration.Parameter param = new io.swagger.models.apideclaration.Parameter();
param.setParamType(ParamType.QUERY);
param.setDescription("a string array query param");
param.setRequired(false);
param.setAllowMultiple(true);
param.setType("string");
Parameter converted = converter.convertParameter(param);
assertTrue(converted.getClass().equals(QueryParameter.class));
QueryParameter qp = (QueryParameter) converted;
assertEquals(qp.getType(), "array");
assertEquals(param.getDescription(), qp.getDescription());
assertNotNull(qp.getItems());
Property items = qp.getItems();
assertEquals(items.getType(), "string");
assertEquals((Boolean) param.getRequired(), (Boolean) qp.getRequired());
assertEquals(qp.getCollectionFormat(), "csv");
}
use of io.swagger.models.parameters.QueryParameter in project swagger-parser by swagger-api.
the class SwaggerParserTest method testIssue292WithCSVCollectionFormat.
@Test
public void testIssue292WithCSVCollectionFormat() {
String yaml = "swagger: '2.0'\n" + "info:\n" + " version: '0.0.0'\n" + " title: nada\n" + "paths:\n" + " /persons:\n" + " get:\n" + " parameters:\n" + " - name: testParam\n" + " in: query\n" + " type: array\n" + " items:\n" + " type: string\n" + " collectionFormat: csv\n" + " responses:\n" + " 200:\n" + " description: Successful response";
SwaggerParser parser = new SwaggerParser();
SwaggerDeserializationResult result = parser.readWithInfo(yaml);
Swagger swagger = result.getSwagger();
Parameter param = swagger.getPaths().get("/persons").getGet().getParameters().get(0);
QueryParameter qp = (QueryParameter) param;
assertEquals(qp.getCollectionFormat(), "csv");
}
use of io.swagger.models.parameters.QueryParameter in project swagger-parser by swagger-api.
the class SwaggerParserTest method testIssue292WithNoCollectionFormat.
@Test
public void testIssue292WithNoCollectionFormat() {
String yaml = "swagger: '2.0'\n" + "info:\n" + " version: '0.0.0'\n" + " title: nada\n" + "paths:\n" + " /persons:\n" + " get:\n" + " parameters:\n" + " - name: testParam\n" + " in: query\n" + " type: array\n" + " items:\n" + " type: string\n" + " responses:\n" + " 200:\n" + " description: Successful response";
SwaggerParser parser = new SwaggerParser();
SwaggerDeserializationResult result = parser.readWithInfo(yaml);
Swagger swagger = result.getSwagger();
Parameter param = swagger.getPaths().get("/persons").getGet().getParameters().get(0);
QueryParameter qp = (QueryParameter) param;
assertNull(qp.getCollectionFormat());
}
use of io.swagger.models.parameters.QueryParameter in project swagger-parser by swagger-api.
the class SwaggerReaderTest method testIssue364.
@Test
public void testIssue364() {
String spec = "swagger: '2.0'\n" + "info:\n" + " title: issue 192\n" + "paths:\n" + " /foo:\n" + " get:\n" + " parameters:\n" + " - name: Code\n" + " in: query\n" + " description: The code\n" + " required: true\n" + " readOnly: true\n" + " allowEmptyValue: true\n" + " responses:\n" + " 200:\n" + " description: 'the pet'";
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(spec);
Swagger swagger = result.getSwagger();
Parameter param = swagger.getPath("/foo").getGet().getParameters().get(0);
assertTrue(param instanceof QueryParameter);
QueryParameter pathParameter = (QueryParameter) param;
assertTrue(pathParameter.isReadOnly());
assertTrue(pathParameter.getAllowEmptyValue());
}
use of io.swagger.models.parameters.QueryParameter in project swagger-parser by swagger-api.
the class SwaggerReaderTest method readSimpleExampleWithMinimumValues.
@Test(description = "it should read the simple example with minimum values")
public void readSimpleExampleWithMinimumValues() {
final SwaggerParser parser = new SwaggerParser();
final Swagger swagger = parser.read("sampleWithMinimumValues.yaml");
final QueryParameter qp = (QueryParameter) swagger.getPaths().get("/pets").getGet().getParameters().get(0);
assertEquals(qp.getMinimum(), new BigDecimal("0.0"));
}
Aggregations