本文整理汇总了Java中io.swagger.models.parameters.QueryParameter类的典型用法代码示例。如果您正苦于以下问题:Java QueryParameter类的具体用法?Java QueryParameter怎么用?Java QueryParameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QueryParameter类属于io.swagger.models.parameters包,在下文中一共展示了QueryParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: map_ReturnsCorrectParameterName_ForQueryParameter
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
@Test
public void map_ReturnsCorrectParameterName_ForQueryParameter() {
// Arrange
QueryParameter queryParameter = new QueryParameter();
queryParameter.setName("param1");
queryParameter.setIn("query");
queryParameter.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
parameter.getIdentifier().stringValue());
Operation operation = new Operation();
operation.addParameter(queryParameter);
MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>();
queryParameters.put(queryParameter.getName(), ImmutableList.of("value", "valueB"));
// Act
Map<String, String> result = mapper.map(operation, product, requestParameters);
// Assert
assertThat(result.size(), is(1));
assertThat(result, hasEntry(parameter.getName(), "value"));
}
示例2: initConverters
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
private static void initConverters() {
// inner converters
for (Class<? extends Property> propertyCls : PROPERTY_MAP.keySet()) {
addInnerConverter(propertyCls);
}
converterMap.put(RefProperty.class, new RefPropertyConverter());
converterMap.put(ArrayProperty.class, new ArrayPropertyConverter());
converterMap.put(MapProperty.class, new MapPropertyConverter());
converterMap.put(StringProperty.class, new StringPropertyConverter());
converterMap.put(ObjectProperty.class, new ObjectPropertyConverter());
converterMap.put(ModelImpl.class, new ModelImplConverter());
converterMap.put(RefModel.class, new RefModelConverter());
converterMap.put(ArrayModel.class, new ArrayModelConverter());
converterMap.put(BodyParameter.class, new BodyParameterConverter());
AbstractSerializableParameterConverter converter = new AbstractSerializableParameterConverter();
converterMap.put(QueryParameter.class, converter);
converterMap.put(PathParameter.class, converter);
converterMap.put(HeaderParameter.class, converter);
converterMap.put(FormParameter.class, converter);
converterMap.put(CookieParameter.class, converter);
}
示例3: createParameterInstance
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
private static Parameter createParameterInstance(ApiImplicitParam paramAnnotation) {
switch (paramAnnotation.paramType()) {
case "path":
return new PathParameter();
case "query":
return new QueryParameter();
case "body":
return new BodyParameter();
case "header":
return new HeaderParameter();
case "form":
return new FormParameter();
case "cookie":
return new CookieParameter();
default:
throw new Error("not support paramType " + paramAnnotation.paramType());
}
}
示例4: testUrlPathBuilder
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
@Test
public void testUrlPathBuilder() throws Exception {
Map<String, RestParam> paramMap = new HashMap<>();
Parameter pathParameter = new PathParameter();
pathParameter.setName("id");
RestParam oRestParam = new RestParam(0, pathParameter, int.class);
paramMap.put(oRestParam.getParamName(), oRestParam);
Parameter queryParameter = new QueryParameter();
queryParameter.setName("q");
oRestParam = new RestParam(1, queryParameter, String.class);
paramMap.put(oRestParam.getParamName(), oRestParam);
URLPathBuilder oURLPathBuilder = new URLPathBuilder("/root/{id}", paramMap);
Object[] args = new Object[] {100, "query"};
Assert.assertEquals("/root/100?q=query", oURLPathBuilder.createRequestPath(args));
Assert.assertEquals("/root/100", oURLPathBuilder.createPathString(args));
}
示例5: opFactoryGetInstances
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
private io.swagger.models.Operation opFactoryGetInstances() {
io.swagger.models.Operation op = new io.swagger.models.Operation();
op.addTag(this.currentTag.getName());
op.setResponses(responseMap(
Operation.STATUS_CODE_OK, responseOk(template(ServiceDocumentQueryResult.class))));
op.setDescription("Query service instances");
for (String[] data : FACTORY_QUERY_PARAMS) {
QueryParameter p = new QueryParameter();
p.setName(data[0]);
p.setDescription(data[1]);
p.setType(data[2]);
p.setExample(data[3]);
p.setDefaultValue(data[4]);
p.setRequired(false);
op.addParameter(p);
}
return op;
}
示例6: scanBeanParamResource
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
@Test
public void scanBeanParamResource() {
final Swagger swagger = getSwagger(ResourceWithBeanParams.class);
final List<Parameter> params = getParameters(swagger, "/bean/{id}");
final HeaderParameter headerParam1 = (HeaderParameter) params.get(0);
assertEquals(1, headerParam1.getDefaultValue());
assertEquals("test order annotation 1", headerParam1.getName());
final HeaderParameter headerParam2 = (HeaderParameter) params.get(1);
assertEquals(2, headerParam2.getDefaultValue());
assertEquals("test order annotation 2", headerParam2.getName());
final QueryParameter priority1 = (QueryParameter) params.get(2);
assertNull(priority1.getDefaultValue());
assertEquals("test priority 1", priority1.getName());
final QueryParameter priority2 = (QueryParameter) params.get(3);
assertEquals(4, priority2.getDefaultValue());
assertEquals("test priority 2", priority2.getName());
final ModelImpl bodyParam1 = (ModelImpl) ((BodyParameter) params.get(4)).getSchema();
assertEquals("bodyParam", bodyParam1.getDefaultValue());
}
示例7: testArrayMulti
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
@Test()
public void testArrayMulti() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setType("array");
parameter.setCollectionFormat("multi");
List<String> paramsList = new ArrayList<>();
paramsList.add("toto");
paramsList.add("tutu");
paramsList.add("titi");
MultiMap params = MultiMap.caseInsensitiveMultiMap();
params.add(name, paramsList);
Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
Assert.assertArrayEquals(paramsList.toArray(), ((List) result).toArray());
}
示例8: testFillQueryStringParameter
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
@Test
public void testFillQueryStringParameter() {
for (int i = 0; i < 100; i++) {
SwagRequest request = new SwagRequest();
QueryParameter param = new QueryParameter();
param.setIn("query");
param.setType("string");
param.setName("testParam");
param.setRequired(true);
ParameterGenerator.fillParameter(swagger.getSwagger(), request, param, TestType.VALID);
assertNotNull(request.getQueryParameters());
assertEquals(1, request.getQueryParameters().size());
assertTrue(request.getQueryParameters().containsKey("testParam"));
assertTrue(request.getQueryParameters().get("testParam") instanceof String);
}
}
示例9: testFillQueryIntParameter
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
@Test
public void testFillQueryIntParameter() {
for (int i = 0; i < 100; i++) {
SwagRequest request = new SwagRequest();
QueryParameter param = new QueryParameter();
param.setIn("query");
param.setType("integer");
param.setName("testParam");
param.setRequired(true);
ParameterGenerator.fillParameter(swagger.getSwagger(), request, param, TestType.VALID);
assertNotNull(request.getQueryParameters());
assertEquals(1, request.getQueryParameters().size());
assertTrue(request.getQueryParameters().containsKey("testParam"));
assertTrue(request.getQueryParameters().get("testParam") instanceof Integer);
}
}
示例10: testFillQueryInt32Parameter
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
@Test
public void testFillQueryInt32Parameter() {
for (int i = 0; i < 100; i++) {
SwagRequest request = new SwagRequest();
QueryParameter param = new QueryParameter();
param.setIn("query");
param.setType("integer");
param.setFormat("int32");
param.setName("testParam");
param.setRequired(true);
ParameterGenerator.fillParameter(swagger.getSwagger(), request, param, TestType.VALID);
assertNotNull(request.getQueryParameters());
assertEquals(1, request.getQueryParameters().size());
assertTrue(request.getQueryParameters().containsKey("testParam"));
assertTrue(request.getQueryParameters().get("testParam") instanceof Integer);
}
}
示例11: testFillQueryInt64Parameter
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
@Test
public void testFillQueryInt64Parameter() {
for (int i = 0; i < 100; i++) {
SwagRequest request = new SwagRequest();
QueryParameter param = new QueryParameter();
param.setIn("query");
param.setType("integer");
param.setFormat("int64");
param.setName("testParam");
param.setRequired(true);
ParameterGenerator.fillParameter(swagger.getSwagger(), request, param, TestType.VALID);
assertNotNull(request.getQueryParameters());
assertEquals(1, request.getQueryParameters().size());
assertTrue(request.getQueryParameters().containsKey("testParam"));
assertTrue(request.getQueryParameters().get("testParam") instanceof Long);
}
}
示例12: contributeGetParameters
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
private boolean contributeGetParameters(final Swagger swagger,
final HttpMethod httpMethod,
final String path,
final Collection<QueryParameter> queryParams)
{
boolean contrib = false;
Optional<Operation> operation = getOperation(swagger, httpMethod, path);
if (operation.isPresent()) {
final Operation op = operation.get();
queryParams.forEach(qp -> {
if (!op.getParameters().contains(qp)) {
log.debug("adding query parameter, method: {}, path: {}, parameter: {}", httpMethod, path, qp.getName());
op.addParameter(qp);
}
});
contrib = true;
}
return contrib;
}
示例13: getSortParameter
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
/**
* @return the JSON-API 'sort' query parameter for some GET operations.
*/
private Parameter getSortParameter() {
List<String> filterAttributes = dictionary.getAttributes(type).stream()
.filter((name) -> {
Class<?> attributeClass = dictionary.getType(type, name);
return (attributeClass.isPrimitive() || String.class.isAssignableFrom(attributeClass));
})
.map((name) -> Arrays.asList(name, "-" + name))
.flatMap(Collection::stream)
.collect(Collectors.toList());
return new QueryParameter()
.name("sort")
.type("array")
.description("Sorts the collection on the selected attributes. A prefix of '-' sorts descending")
.items(new StringProperty()._enum(filterAttributes))
.collectionFormat("csv");
}
示例14: testSortParam
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
@Test
public void testSortParam() throws Exception {
List<Parameter> params = swagger.getPaths().get("/book").getGet().getParameters();
Set<String> paramNames = params.stream()
.map((param) -> param.getName())
.collect(Collectors.toSet());
long sortParams = paramNames.stream().filter((name) -> name.startsWith("sort")).count();
Assert.assertEquals(sortParams, 1);
Assert.assertTrue(paramNames.contains("sort"));
QueryParameter sortParam = (QueryParameter) params.stream()
.filter((param) -> param.getName().equals("sort"))
.findFirst()
.get();
Assert.assertEquals(sortParam.getIn(), "query");
List<String> sortValues = Arrays.asList("title", "-title");
Assert.assertTrue(((StringProperty) sortParam.getItems()).getEnum().containsAll(sortValues));
Assert.assertEquals(sortParam.getCollectionFormat(), "csv");
}
示例15: testIncludeParam
import io.swagger.models.parameters.QueryParameter; //导入依赖的package包/类
@Test
public void testIncludeParam() throws Exception {
List<Parameter> params = swagger.getPaths().get("/book").getGet().getParameters();
Set<String> paramNames = params.stream()
.map((param) -> param.getName())
.collect(Collectors.toSet());
long includeParams = paramNames.stream().filter((name) -> name.startsWith("include")).count();
Assert.assertEquals(includeParams, 1);
Assert.assertTrue(paramNames.contains("include"));
QueryParameter includeParam = (QueryParameter) params.stream()
.filter((param) -> param.getName().equals("include"))
.findFirst()
.get();
Assert.assertEquals(includeParam.getIn(), "query");
List<String> sortValues = Arrays.asList("authors", "publisher");
Assert.assertTrue(((StringProperty) includeParam.getItems()).getEnum().containsAll(sortValues));
Assert.assertEquals(includeParam.getCollectionFormat(), "csv");
}