Java Code Examples for io.swagger.models.parameters.Parameter#getIn()
The following examples show how to use
io.swagger.models.parameters.Parameter#getIn() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotOnlyEnumValuesRule.java From swagger-coverage with Apache License 2.0 | 6 votes |
@Override public Condition processParameter(Parameter parameter) { List<String> enumValues = SwaggerSpecificationProcessor.extractEnum(parameter); if (enumValues != null && !enumValues.isEmpty()) { ConditionPredicate predicate = new NotOnlyParameterListValueConditionPredicate( parameter.getName(), parameter.getIn(), enumValues ); return new SinglePredicateCondition( String.format("%s «%s» contains values not only from enum", parameter.getIn(), parameter.getName()), "", predicate ); } return null; }
Example 2
Source File: EnumAllValuesRule.java From swagger-coverage with Apache License 2.0 | 5 votes |
@Override public Condition processParameter(Parameter parameter) { List<String> enumValues = SwaggerSpecificationProcessor.extractEnum(parameter); if (enumValues != null && !enumValues.isEmpty()) { ConditionPredicate predicate = new ParameterValueConditionPredicate(parameter.getName(), parameter.getIn(), enumValues); return new SinglePredicateCondition( String.format("%s «%s» contains all values from enum %s", parameter.getIn(), parameter.getName(), enumValues), "", predicate ); } return null; }
Example 3
Source File: NotEmptyParameterRule.java From swagger-coverage with Apache License 2.0 | 5 votes |
@Override public Condition processParameter(Parameter parameter) { if (parameter instanceof BodyParameter) { return null; } ConditionPredicate predicate = new DefaultParameterConditionPredicate(false, parameter.getName(), parameter.getIn()); return new SinglePredicateCondition( String.format("%s «%s» is not empty", parameter.getIn(), parameter.getName()), "", predicate ); }
Example 4
Source File: EmptyHeaderRule.java From swagger-coverage with Apache License 2.0 | 5 votes |
@Override public Condition processParameter(Parameter parameter) { if (parameter instanceof HeaderParameter) { ConditionPredicate predicate = new DefaultParameterConditionPredicate(true, parameter.getName(), parameter.getIn()); return new SinglePredicateCondition( String.format("header «%s» is empty", parameter.getName()), "", predicate ); } return null; }
Example 5
Source File: RestParam.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
protected void init(Parameter parameter, Type genericParamType) { String paramType = parameter.getIn(); ParamValueProcessorCreator creater = ParamValueProcessorCreatorManager.INSTANCE.ensureFindValue(paramType); this.setParamProcessor(creater.create(parameter, genericParamType)); }
Example 6
Source File: ApiGatewaySdkSwaggerApiImporter.java From aws-apigateway-importer with Apache License 2.0 | 5 votes |
private Optional<String> getParameterLocation(Parameter p) { switch (p.getIn()) { case "path": return Optional.of("path"); case "query": return Optional.of("querystring"); case "header": return Optional.of("header"); default: LOG.warn("Parameter type " + p.getIn() + " not supported, skipping"); break; } return Optional.empty(); }
Example 7
Source File: DefaultGenerator.java From TypeScript-Microservices with MIT License | 4 votes |
private static String generateParameterId(Parameter parameter) { return parameter.getName() + ":" + parameter.getIn(); }
Example 8
Source File: HttpRuleGenerator.java From api-compiler with Apache License 2.0 | 4 votes |
/** Creates {@link HttpRule} from a swagger operation. */ HttpRule createHttpRule(Operation operation, Path parentPath, String operationType, String path) { HttpRule.Builder httpRuleBuilder = HttpRule.newBuilder(); ImmutableList<Parameter> allParameters = ProtoApiFromOpenApi.getAllResolvedParameters( operation, parentPath, diagCollector, OpenApiLocations.createOperationLocation(operationType, path)); httpRuleBuilder.setSelector( namespacePrefix + NameConverter.operationIdToMethodName(operation.getOperationId())); for (Parameter parameter : allParameters) { String paramNameWithUnderScore = NameConverter.getFieldName(parameter.getName()); switch (parameter.getIn()) { case "body": httpRuleBuilder.setBody(paramNameWithUnderScore); break; case "query": case "path": path = path.replace("{" + parameter.getName() + "}", "{" + paramNameWithUnderScore + "}"); break; default: /* TODO(user): Support other In types.*/ } } String httpRulePath = basePath + path; switch (operationType) { case "put": httpRuleBuilder.setPut(httpRulePath); break; case "get": httpRuleBuilder.setGet(httpRulePath); break; case "delete": httpRuleBuilder.setDelete(httpRulePath); break; case "patch": httpRuleBuilder.setPatch(httpRulePath); break; case "post": httpRuleBuilder.setPost(httpRulePath); break; default: httpRuleBuilder.setCustom( CustomHttpPattern.newBuilder() .setKind(operationType.toUpperCase()) .setPath(httpRulePath) .build()); } return httpRuleBuilder.build(); }
Example 9
Source File: ConsumerDrivenValidator.java From assertj-swagger with Apache License 2.0 | 2 votes |
/** * Generates a unique key for a parameter. * <p> * From <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterObject" target="_top">OpenAPI Specification</a> * "A unique parameter is defined by a combination of a name and location." * * @param parameter the parameter to generate a unique key for * @return a unique key based on name and location ({@link Parameter#getIn()}) */ private String parameterUniqueKey(Parameter parameter) { return parameter.getName() + parameter.getIn(); }