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


Java PathParameter类代码示例

本文整理汇总了Java中io.swagger.models.parameters.PathParameter的典型用法代码示例。如果您正苦于以下问题:Java PathParameter类的具体用法?Java PathParameter怎么用?Java PathParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PathParameter类属于io.swagger.models.parameters包,在下文中一共展示了PathParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initConverters

import io.swagger.models.parameters.PathParameter; //导入依赖的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);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:ConverterMgr.java

示例2: createParameterInstance

import io.swagger.models.parameters.PathParameter; //导入依赖的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());
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:AnnotationUtils.java

示例3: testUrlPathBuilder

import io.swagger.models.parameters.PathParameter; //导入依赖的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));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:20,代码来源:TestPath.java

示例4: validatePath

import io.swagger.models.parameters.PathParameter; //导入依赖的package包/类
public Result validatePath(ResourcePath path, boolean strict) throws ValidationException {
    Result result = new Result();
    ResourcePath swaggerPath = getSwaggerRequest().getPath();
    if (strict) {
        // validate path segments
        if (swaggerPath.getSegments().length < path.getSegments().length) {
            String unknownPath = "";
            for (int i = swaggerPath.getSegments().length; i < path.getSegments().length; i++)
                unknownPath += "/" + path.getSegment(i);
            result.also(Status.BAD_REQUEST, "Unknown path suffix: " + unknownPath);
        }
    }
    List<PathParameter> pathParams = getSwaggerRequest().getPathParameters();
    for (int i = 0; i < pathParams.size(); i++) {
        PathParameter pathParam = pathParams.get(i);
        for (ParameterValidator<? extends Parameter> validator : parameterValidators.getValidators(pathParam)) {
            result.also(validator.doValidate(getSwaggerRequest(), pathParam, path.getSegment(i), strict));
        }
    }
    return result;
}
 
开发者ID:limberest,项目名称:limberest,代码行数:22,代码来源:SwaggerValidator.java

示例5: map_ReturnsEmptyMap_WhenParameterHasNoParameterInputVendorExtension

import io.swagger.models.parameters.PathParameter; //导入依赖的package包/类
@Test
public void map_ReturnsEmptyMap_WhenParameterHasNoParameterInputVendorExtension() {
  // Arrange
  Operation operation = new Operation();
  PathParameter pathParameter = new PathParameter();

  pathParameter.setVendorExtension("x-dotwebstack-another-vendor-extension",
      parameter.getIdentifier().stringValue());
  operation.setParameters(ImmutableList.of(pathParameter));

  // Act
  Map<String, String> result = mapper.map(operation, product, requestParameters);

  // Assert
  assertThat(result.isEmpty(), is(true));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:17,代码来源:RequestParameterMapperTest.java

示例6: map_ThrowsException_ForUnknownParameterName

import io.swagger.models.parameters.PathParameter; //导入依赖的package包/类
@Test
public void map_ThrowsException_ForUnknownParameterName() {
  // Assert
  thrown.expect(ConfigurationException.class);
  thrown.expectMessage("No parameter found for vendor extension value:");

  // Arrange
  Operation operation = new Operation();
  PathParameter parameter = new PathParameter();

  parameter.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER, "http://unknown");
  operation.setParameters(ImmutableList.of(parameter));

  // Act
  mapper.map(operation, product, requestParameters);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:17,代码来源:RequestParameterMapperTest.java

示例7: testFillPathStringParameter

import io.swagger.models.parameters.PathParameter; //导入依赖的package包/类
@Test
public void testFillPathStringParameter() {
	for (int i = 0; i < 100; i++) {
		SwagRequest request = new SwagRequest();

		PathParameter param = new PathParameter();
		param.setIn("path");
		param.setType("string");
		param.setFormat("date");
		param.setName("testParam");
		param.setRequired(true);

		ParameterGenerator.fillParameter(swagger.getSwagger(), request, param, TestType.VALID);

		assertNotNull(request.getPathParameters());
		assertEquals(1, request.getPathParameters().size());
		assertTrue(request.getPathParameters().containsKey("testParam"));
		assertTrue(request.getPathParameters().get("testParam") instanceof String);
	}
}
 
开发者ID:lpelleau,项目名称:SwagTester,代码行数:21,代码来源:TestParameterGenerator.java

示例8: getParameter

import io.swagger.models.parameters.PathParameter; //导入依赖的package包/类
private static Parameter getParameter(Map.Entry<String, Boolean> parameterEntry) {
	Parameter parameter;
	String parameterName = parameterEntry.getKey();
	if (parameterName.startsWith(METHOD_REQUEST_PATH)) {
		parameter = new PathParameter()
				.name(parameterName.substring(METHOD_REQUEST_PATH.length()))
				.type("string"); 	//There is no type information for params in API gateway
	} else if (parameterName.startsWith(METHOD_REQUEST_QUERYSTRING)) {
		parameter = new QueryParameter() 
				.name(parameterName.substring(METHOD_REQUEST_QUERYSTRING.length()))
				.type("string");
	} else if (parameterName.startsWith(METHOD_REQUEST_HEADER)) {
		parameter = new HeaderParameter()
				.name(parameterName.substring(METHOD_REQUEST_HEADER.length()))
				.type("string");
	} else {
		throw new UnsupportedOperationException("Unsupported request parameter type " + parameterName);
	}
	parameter.setRequired(parameterEntry.getValue());
	return parameter;
}
 
开发者ID:isabinin,项目名称:aws-apigateway-swagger-exporter,代码行数:22,代码来源:APIGExporter.java

示例9: testCreate

import io.swagger.models.parameters.PathParameter; //导入依赖的package包/类
@Test
public void testCreate() {
  ParamValueProcessorCreator creator =
      ParamValueProcessorCreatorManager.INSTANCE.findValue(PathProcessorCreator.PARAMTYPE);
  Parameter parameter = new PathParameter();
  parameter.setName("path");

  ParamValueProcessor processor = creator.create(parameter, String.class);

  Assert.assertEquals(PathProcessor.class, processor.getClass());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:12,代码来源:TestPathProcessorCreator.java

示例10: addDefaultValidators

import io.swagger.models.parameters.PathParameter; //导入依赖的package包/类
protected void addDefaultValidators() {
    addValidator(StringProperty.class, new StringPropertyValidator());
    addValidator(AbstractNumericProperty.class, new NumberPropertyValidator());
    addValidator(PathParameter.class, new PathParameterValidator());
    addValidator(QueryParameter.class, new QueryParameterValidator());
    addValidator(HeaderParameter.class, new HeaderParameterValidator());
    addValidator(BodyParameter.class, new BodyParameterValidator(propertyValidators));
}
 
开发者ID:limberest,项目名称:limberest,代码行数:9,代码来源:SwaggerValidator.java

示例11: getPathParameters

import io.swagger.models.parameters.PathParameter; //导入依赖的package包/类
public List<PathParameter> getPathParameters() {
    List<PathParameter> pathParams = new ArrayList<>();
    for (Parameter param : getParameters()) {
        if (param instanceof PathParameter)
            pathParams.add((PathParameter)param);
    }
    return pathParams;
}
 
开发者ID:limberest,项目名称:limberest,代码行数:9,代码来源:SwaggerRequest.java

示例12: paramId

import io.swagger.models.parameters.PathParameter; //导入依赖的package包/类
private Parameter paramId() {
    PathParameter res = new PathParameter();
    res.setName(PARAM_NAME_ID);
    res.setRequired(true);
    res.setType(StringProperty.TYPE);
    return res;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:8,代码来源:SwaggerAssembler.java

示例13: paramPath

import io.swagger.models.parameters.PathParameter; //导入依赖的package包/类
private Parameter paramPath(RequestRouter.Parameter routeParam) {
    PathParameter pathParam = new PathParameter();
    pathParam.setName(routeParam.name);
    pathParam.setDescription(routeParam.description);
    pathParam.setRequired(routeParam.required);
    // Setting the type to be lowercase so that we match the swagger type.
    pathParam.setType(routeParam.type != null ? routeParam.type.toLowerCase() : "");
    pathParam.setDefaultValue(routeParam.value);
    return pathParam;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:11,代码来源:SwaggerAssembler.java

示例14: map_ReturnsCorrectParameterName_ForPathParameters

import io.swagger.models.parameters.PathParameter; //导入依赖的package包/类
@Test
public void map_ReturnsCorrectParameterName_ForPathParameters() {
  // Arrange
  PathParameter pathParameter = new PathParameter();

  pathParameter.setName("param1");
  pathParameter.setIn("path");

  // Note this parameter has multiple vendor extensions
  pathParameter.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
      parameter.getIdentifier().stringValue());
  pathParameter.setVendorExtension("x-dotwebstack-another-vendor-extension", "foo");

  // Note this operation has multiple parameters
  Operation operation = new Operation();
  operation.addParameter(pathParameter);

  PathParameter pathParameter2 = new PathParameter();

  pathParameter2.setName("param2");
  pathParameter2.setIn("path");
  pathParameter2.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
      parameter2.getIdentifier().stringValue());

  operation.addParameter(pathParameter2);

  MultivaluedMap<String, String> pathParameters = new MultivaluedHashMap<>();

  // Note there are multiple values for this parameter, to test that the first value is used only
  pathParameters.put(pathParameter.getName(), ImmutableList.of("value", "valueB"));
  pathParameters.put(pathParameter2.getName(), ImmutableList.of("value2"));

  // Act
  Map<String, String> result = mapper.map(operation, product, requestParameters);

  // Assert
  assertThat(result.size(), is(2));
  assertThat(result, hasEntry(parameter.getName(), "value"));
  assertThat(result, hasEntry(parameter2.getName(), "value2"));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:41,代码来源:RequestParameterMapperTest.java

示例15: buildPathParameter

import io.swagger.models.parameters.PathParameter; //导入依赖的package包/类
private PathParameter buildPathParameter(VariableElement variableElement, PathVariable pathVariable) {
    Property property = ofNullable(propertyUtils.toSimpleProperty(variableElement))
            .filter(prop -> !(prop instanceof ObjectProperty))
            .orElseGet(StringProperty::new);
    return new PathParameter()
            .name(pathVariable.value())
            .required(true)
            .property(property);
}
 
开发者ID:Cosium,项目名称:openapi-annotation-processor,代码行数:10,代码来源:SpringParser.java


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