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


Java Parameter类代码示例

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


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

示例1: shouldCreatePropertyParametersFromPetstoreSwagger

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
@Test
public void shouldCreatePropertyParametersFromPetstoreSwagger() throws IOException {
    final String specification = resource("/swagger/petstore.swagger.json");
    final Swagger swagger = new SwaggerParser().parse(specification);

    final Parameter petIdPathParameter = swagger.getPath("/pet/{petId}").getGet().getParameters().get(0);

    final Optional<ConfigurationProperty> maybeConfigurationProperty = BaseSwaggerConnectorGenerator
        .createPropertyFromParameter(petIdPathParameter);

    final ConfigurationProperty expected = new ConfigurationProperty.Builder()//
        .componentProperty(false)//
        .deprecated(false)//
        .description("ID of pet to return")//
        .displayName("petId")//
        .group("producer")//
        .javaType(Long.class.getName())//
        .kind("property")//
        .required(true)//
        .secret(false)//
        .type("integer")//
        .build();

    assertThat(maybeConfigurationProperty).hasValue(expected);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:26,代码来源:BaseSwaggerConnectorGeneratorTest.java

示例2: read

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
public static void read(Swagger swagger, Map<Class<?>, Object> interfaceMapRef,
		String httpContext) {
	final Reader reader = new Reader(swagger);
	List<Entry<Class<?>, Object>> arrayList = new ArrayList<Entry<Class<?>, Object>>(interfaceMapRef.entrySet());
	Collections.sort(arrayList, new Comparator<Entry<Class<?>, Object>>() {
		@Override
		public int compare(Entry<Class<?>, Object> o1, Entry<Class<?>, Object> o2) {
			return o1.getKey().getSimpleName().compareTo(o2.getKey().getSimpleName());
		}
	});
	for (Entry<Class<?>, Object> entry : arrayList) {
		final ReaderContext context = new ReaderContext(swagger,
				entry.getValue().getClass(), entry.getKey(), httpContext, null, false,
				new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(),
				new ArrayList<Parameter>());
		reader.read(context);
	}
}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:19,代码来源:Reader.java

示例3: validate

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
@Override
public Status validate(final String value, final Parameter p) {

    if (!supports(p)) {
        return null;
    }

    final SerializableParameter parameter = (SerializableParameter)p;

    if (parameter.getRequired() && (value == null || value.trim().isEmpty())) {
        return new Status("ERR11001", parameter.getName());
    }

    if (value == null || value.trim().isEmpty()) {
        return null;
    }

    return doValidate(value, parameter);
}
 
开发者ID:networknt,项目名称:light-rest-4j,代码行数:20,代码来源:ArrayParameterValidator.java

示例4: copyToSwaggerParameters

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
protected void copyToSwaggerParameters() {
  for (Parameter parameter : providerParameters) {
    if (ContextParameter.class.isInstance(parameter)) {
      continue;
    }

    int annotationIdx = ParamUtils.findParameterByName(parameter.getName(), methodAnnotationParameters);
    if (annotationIdx != -1) {
      Parameter annotationParameter = methodAnnotationParameters.remove(annotationIdx);
      swaggerParameters.add(annotationParameter);
      continue;
    }

    swaggerParameters.add(parameter);
  }

  swaggerParameters.addAll(methodAnnotationParameters);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:OperationGenerator.java

示例5: validate

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
@Override
public Status validate(final String value, final Parameter p) {

    if (!supports(p)) {
        return null;
    }

    final SerializableParameter parameter = (SerializableParameter)p;

    if (parameter.getRequired() && (value == null || value.trim().isEmpty())) {
        return new Status("ERR11001", p.getName());
    }

    if (value == null || value.trim().isEmpty()) {
        return null;
    }

    if (!matchesEnumIfDefined(value, parameter)) {
        return new Status("ERR11002", value, parameter.getName(), parameter.getEnum());
    }
    return doValidate(value, parameter);
}
 
开发者ID:networknt,项目名称:light-rest-4j,代码行数:23,代码来源:BaseParameterValidator.java

示例6: testUrlPathBuilder

import io.swagger.models.parameters.Parameter; //导入依赖的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

示例7: validateHeader

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
private Status validateHeader(final HttpServerExchange exchange,
                              final SwaggerOperation swaggerOperation,
                              final Parameter headerParameter) {

    final HeaderValues headerValues = exchange.getRequestHeaders().get(headerParameter.getName());
    if ((headerValues == null || headerValues.isEmpty())) {
        if(headerParameter.getRequired()) {
            return new Status(VALIDATOR_REQUEST_PARAMETER_HEADER_MISSING, headerParameter.getName(), swaggerOperation.getPathString().original());
        }
    } else {

        Optional<Status> optional = headerValues
                .stream()
                .map((v) -> parameterValidators.validate(v, headerParameter))
                .filter(s -> s != null)
                .findFirst();
        if(optional.isPresent()) {
            return optional.get();
        }
    }
    return null;
}
 
开发者ID:networknt,项目名称:light-rest-4j,代码行数:23,代码来源:RequestValidator.java

示例8: validatePath

import io.swagger.models.parameters.Parameter; //导入依赖的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

示例9: testApplyParameters

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
@SuppressWarnings({  "serial" })
	@Test
	public void testApplyParameters(){
		Swagger swagger = new Swagger();
		Reader.read(swagger, new HashMap<Class<?>, Object>(){{
			put(InterfaceServiceTest.class, new InterfaceServiceImplTest());
		}}, "/h");
		
//		System.out.println(Json.pretty(swagger));
		
		Path path = swagger.getPaths().get("/h/com.deepoove.swagger.dubbo.api.InterfaceServiceTest/test");
		Assert.assertNotNull(path);
		Operation operation = path.getOperationMap().get(HttpMethod.POST);
		Assert.assertNotNull(operation);
		Assert.assertNotNull(operation.getParameters());
		
		List<Parameter> parameters = operation.getParameters();
		Assert.assertTrue(parameters.get(0).getName().equals("para"));
		Assert.assertTrue(parameters.get(1).getName().equals("code"));
		
	}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:22,代码来源:ReaderTest.java

示例10: path2UtilSubscriptions

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
private Path path2UtilSubscriptions(Parameter idParam) {
    Path path = new Path();
    if (idParam != null) {
        path.setParameters(Collections.singletonList(paramId()));
    }

    ServiceDocument subscriptionState = template(ServiceSubscriptionState.class);
    path.setGet(opDefault(subscriptionState));

    io.swagger.models.Operation deleteOrPost = new io.swagger.models.Operation();
    deleteOrPost.addParameter(paramBody(template(ServiceSubscriber.class)));
    deleteOrPost.addTag(this.currentTag.getName());
    deleteOrPost.setResponses(responseMap(
            Operation.STATUS_CODE_OK, responseOk(subscriptionState)));
    path.setDelete(deleteOrPost);
    path.setPost(deleteOrPost);
    return path;

}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:20,代码来源:SwaggerAssembler.java

示例11: path2UtilConfig

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
private Path path2UtilConfig(Parameter idParam) {
    Path path = new Path();
    if (idParam != null) {
        path.setParameters(Collections.singletonList(paramId()));
    }
    io.swagger.models.Operation op = new io.swagger.models.Operation();
    op.addTag(this.currentTag.getName());

    op.setResponses(responseMap(
            Operation.STATUS_CODE_OK, responseOk(template(ServiceConfiguration.class)),
            Operation.STATUS_CODE_NOT_FOUND, responseGenericError()));
    path.setGet(op);

    op = new io.swagger.models.Operation();
    op.addTag(this.currentTag.getName());
    op.setParameters(
            Collections.singletonList(paramBody(ServiceConfigUpdateRequest.class)));
    op.setResponses(responseMap(
            Operation.STATUS_CODE_OK, responseOk(template(ServiceConfiguration.class)),
            Operation.STATUS_CODE_NOT_FOUND, responseGenericError()));
    path.setPatch(op);

    return path;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:25,代码来源:SwaggerAssembler.java

示例12: validateQueryParameter

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
private Status validateQueryParameter(final HttpServerExchange exchange,
                                      final SwaggerOperation swaggerOperation,
                                      final Parameter queryParameter) {

    final Collection<String> queryParameterValues = exchange.getQueryParameters().get(queryParameter.getName());

    if ((queryParameterValues == null || queryParameterValues.isEmpty())) {
        if(queryParameter.getRequired()) {
            return new Status(VALIDATOR_REQUEST_PARAMETER_QUERY_MISSING, queryParameter.getName(), swaggerOperation.getPathString().original());
        }
    } else {

        Optional<Status> optional = queryParameterValues
                .stream()
                .map((v) -> parameterValidators.validate(v, queryParameter))
                .filter(s -> s != null)
                .findFirst();
        if(optional.isPresent()) {
            return optional.get();
        }
    }
    return null;
}
 
开发者ID:networknt,项目名称:light-rest-4j,代码行数:24,代码来源:RequestValidator.java

示例13: paramBody

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
/**
 * Build BodyParameter for the Route parameter of type body.
 */
private BodyParameter paramBody(List<RequestRouter.Parameter> routeParams, Route route) {
    BodyParameter bodyParam = new BodyParameter();
    bodyParam.setRequired(false);

    Model model = new ModelImpl();
    if (routeParams != null) {
        Map<String, Property> properties = new HashMap<>(routeParams.size());
        routeParams.stream().forEach((p) -> {
            StringProperty stringProperty = new StringProperty();
            stringProperty.setName(p.name);
            stringProperty
                    .setDescription(isBlank(p.description) ? route.description : p.description);
            stringProperty.setDefault(p.value);
            stringProperty.setRequired(p.required);
            stringProperty.setType(StringProperty.TYPE);

            properties.put(p.name, stringProperty);
        });
        model.setProperties(properties);
    }
    bodyParam.setSchema(model);
    return bodyParam;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:27,代码来源:SwaggerAssembler.java

示例14: extractBodyParameter

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
/**
 * Extracts the body from the supplied request.
 */
private static void extractBodyParameter(final RequestParameters requestParameters,
    final ContainerRequestContext ctx, final Optional<Parameter> parameter) throws IOException {

  String body = extractBody(ctx);
  if (body == null) {
    return;
  }
  requestParameters.setRawBody(body);
  if (!parameter.isPresent()) {
    return;
  }

  if (ctx.getHeaders().get(HttpHeaders.CONTENT_TYPE).stream().filter(
      header -> ContentType.APPLICATION_JSON.toString().startsWith(header)).findAny().orElse(
          null) == null) {
    return;
  }

  ObjectMapper objectMapper = new ObjectMapper();
  Map json = objectMapper.readValue(body, Map.class);
  if (json.keySet().size() == 1) {
    requestParameters.putAll(json);
  }

}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:29,代码来源:RequestParameterExtractor.java

示例15: map_BodyParameter

import io.swagger.models.parameters.Parameter; //导入依赖的package包/类
@Test
public void map_BodyParameter() throws IOException {
  // Arrange
  Property property = mock(Property.class);
  List<Parameter> parameters = createBodyParameter("object");
  Operation newOp = new Operation();
  newOp.setParameters(parameters);
  newOp.vendorExtensions(ImmutableMap.of(OpenApiSpecificationExtensions.INFORMATION_PRODUCT,
      DBEERPEDIA.BREWERIES.stringValue()));
  newOp.response(200, new Response().schema(property));
  mockDefinition().host(DBEERPEDIA.OPENAPI_HOST).produces(MediaType.APPLICATION_JSON).path(
      "/breweries", new Path().get(newOp));

  // Act
  requestMapper.map(httpConfigurationMock);

  // Assert
  verify(httpConfigurationMock).registerResources(resourceCaptor.capture());
  Resource resource = resourceCaptor.getValue();
  assertThat(resource.getPath(), equalTo("/" + DBEERPEDIA.OPENAPI_HOST + "/breweries"));

}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:23,代码来源:OpenApiRequestMapperTest.java


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