当前位置: 首页>>代码示例>>Java>>正文


Java QueryParameter.setName方法代码示例

本文整理汇总了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"));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:24,代码来源:RequestParameterMapperTest.java

示例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;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:20,代码来源:SwaggerAssembler.java

示例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);
	}
}
 
开发者ID:lpelleau,项目名称:SwagTester,代码行数:20,代码来源:TestParameterGenerator.java

示例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);
	}
}
 
开发者ID:lpelleau,项目名称:SwagTester,代码行数:20,代码来源:TestParameterGenerator.java

示例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);
	}
}
 
开发者ID:lpelleau,项目名称:SwagTester,代码行数:21,代码来源:TestParameterGenerator.java

示例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);
	}
}
 
开发者ID:lpelleau,项目名称:SwagTester,代码行数:21,代码来源:TestParameterGenerator.java

示例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;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:15,代码来源:SwaggerAssembler.java

示例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;
}
 
开发者ID:kongchen,项目名称:swagger-maven-plugin,代码行数:61,代码来源:SpringSwaggerExtension.java


注:本文中的io.swagger.models.parameters.QueryParameter.setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。