本文整理汇总了Java中io.swagger.models.parameters.QueryParameter.setName方法的典型用法代码示例。如果您正苦于以下问题:Java QueryParameter.setName方法的具体用法?Java QueryParameter.setName怎么用?Java QueryParameter.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.swagger.models.parameters.QueryParameter
的用法示例。
在下文中一共展示了QueryParameter.setName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: process
import io.swagger.models.parameters.QueryParameter; //导入方法依赖的package包/类
@Override
public void process(OperationGenerator operationGenerator, int paramIdx) {
String paramName = ParamUtils.getParameterName(operationGenerator.getProviderMethod(), paramIdx);
QueryParameter queryParameter = new QueryParameter();
queryParameter.setName(paramName);
ParamUtils.setParameterType(operationGenerator.getSwagger(),
operationGenerator.getProviderMethod(),
paramIdx,
queryParameter);
operationGenerator.addProviderParameter(queryParameter);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:13,代码来源:SpringmvcDefaultParameterProcessor.java
示例8: paramQuery
import io.swagger.models.parameters.QueryParameter; //导入方法依赖的package包/类
/**
* Build QueryParameter for the Route parameter of type query.
*/
private QueryParameter paramQuery(RequestRouter.Parameter routeParam, Route route) {
QueryParameter queryParam = new QueryParameter();
queryParam.setName(routeParam.name);
queryParam.setDescription(isBlank(routeParam.description) ? route.description
: routeParam.description);
queryParam.setRequired(routeParam.required);
// Setting the type to be lowercase so that we match the swagger type.
queryParam.setType(routeParam.type != null ? routeParam.type.toLowerCase() : "");
queryParam.setDefaultValue(routeParam.value);
return queryParam;
}
示例9: extractParametersFromModelAttributeAnnotation
import io.swagger.models.parameters.QueryParameter; //导入方法依赖的package包/类
private List<Parameter> extractParametersFromModelAttributeAnnotation(Annotation annotation, Type type) {
if (!(annotation instanceof ModelAttribute)) {
return null;
}
Class<?> cls = TypeUtils.getRawType(type, type);
List<Parameter> parameters = new ArrayList<Parameter>();
for (PropertyDescriptor propertyDescriptor : BeanUtils.getPropertyDescriptors(cls)) {
// Get all the valid setter methods inside the bean
Method propertyDescriptorSetter = propertyDescriptor.getWriteMethod();
if (propertyDescriptorSetter != null) {
ApiParam propertySetterApiParam = AnnotationUtils.findAnnotation(propertyDescriptorSetter, ApiParam.class);
if (propertySetterApiParam == null) {
// If we find a setter that doesn't have @ApiParam annotation, then skip it
continue;
}
// Here we have a bean setter method that is annotted with @ApiParam, but we still
// need to know what type of parameter to create. In order to do this, we look for
// any annotation attached to the first method parameter of the setter fucntion.
Annotation[][] methodAnnotations = propertyDescriptorSetter.getParameterAnnotations();
if (methodAnnotations == null || methodAnnotations.length == 0) {
continue;
}
String defaultValue = "";
Parameter propertySetterExtractedParameter = null;
for (Annotation firstMethodParameterAnnotation : methodAnnotations[0]) {
Class parameterClass = propertyDescriptor.getPropertyType();
propertySetterExtractedParameter = this.extractParameterFromAnnotation(
firstMethodParameterAnnotation, defaultValue, parameterClass);
if (propertySetterExtractedParameter != null) {
// When we find a valid parameter type to use, keep it
break;
}
}
if (propertySetterExtractedParameter == null) {
QueryParameter queryParameter = new QueryParameter().name(propertyDescriptor.getDisplayName())
.description(propertySetterApiParam.value())
.required(propertySetterApiParam.required());
queryParameter.setAccess(propertySetterApiParam.access());
Property schema = ModelConverters.getInstance()
.readAsProperty(propertyDescriptor.getPropertyType());
if (schema != null) {
queryParameter.setProperty(schema);
}
if (!propertySetterApiParam.name().isEmpty()) {
queryParameter.setName(propertySetterApiParam.name());
}
parameters.add(queryParameter);
} else {
parameters.add(propertySetterExtractedParameter);
}
}
}
return parameters;
}