Java Code Examples for io.swagger.v3.oas.models.parameters.Parameter#getIn()

The following examples show how to use io.swagger.v3.oas.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: OASMergeUtil.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
public static Parameter mergeParameter(Parameter thisParameter, Parameter thatParameter) {
  if (thatParameter.getName() != null) {
    thisParameter.setName(thatParameter.getName());
  }
  if (thatParameter.getIn() != null) {
    thisParameter.setIn(thatParameter.getIn());
  }
  if (thatParameter.getDescription() != null) {
    thisParameter.setDescription(thatParameter.getDescription());
  }
  if (thatParameter.getRequired() != null) {
    thisParameter.setRequired(thatParameter.getRequired());
  }
  if (thatParameter.getDeprecated() != null) {
    thisParameter.setDeprecated(thatParameter.getDeprecated());
  }
  if (thatParameter.getAllowEmptyValue() != null) {
    thisParameter.setAllowEmptyValue(thatParameter.getAllowEmptyValue());
  }
  if (thatParameter.get$ref() != null) {
    thisParameter.set$ref(thatParameter.get$ref());
  }
  return thisParameter;
}
 
Example 2
Source File: InputModeller.java    From tcases with MIT License 6 votes vote down vote up
/**
 * Returns the style of the given parameter.
 */
private Parameter.StyleEnum parameterStyle( Parameter parameter, String parameterType)
  {
  String in = parameter.getIn();
  
  return
    parameter.getStyle() != null?
    getApplicableStyle( parameter, parameterType) :

    in.equals( "path")?
    Parameter.StyleEnum.SIMPLE :

    in.equals( "header")?
    Parameter.StyleEnum.SIMPLE :

    Parameter.StyleEnum.FORM;
  }
 
Example 3
Source File: OpenAPI3RequestValidationHandlerImpl.java    From vertx-web with Apache License 2.0 6 votes vote down vote up
private void magicParameterExplodedStyleSimpleTypeObject(Parameter parameter) {
  ObjectTypeValidator objectTypeValidator = ObjectTypeValidator.ObjectTypeValidatorFactory
    .createObjectTypeValidator(ContainerSerializationStyle.simple_exploded_object, false);
  this.resolveObjectTypeFields(objectTypeValidator, parameter.getSchema());
  switch (parameter.getIn()) {
    case "path":
      this.addPathParamRule(ParameterValidationRuleImpl.ParameterValidationRuleFactory
        .createValidationRuleWithCustomTypeValidator(parameter.getName(), objectTypeValidator, !OpenApi3Utils
          .isRequiredParam(parameter), OpenApi3Utils.resolveAllowEmptyValue(parameter), ParameterLocation.PATH));
      break;
    case "header":
      this.addHeaderParamRule(ParameterValidationRuleImpl.ParameterValidationRuleFactory
        .createValidationRuleWithCustomTypeValidator(parameter.getName(), objectTypeValidator, !OpenApi3Utils
          .isRequiredParam(parameter), OpenApi3Utils.resolveAllowEmptyValue(parameter), ParameterLocation.HEADER));
      break;
    default:
      throw new SpecFeatureNotSupportedException("combination of style, type and location (in) of parameter fields "
        + "not supported for parameter " + parameter.getName());
  }
}
 
Example 4
Source File: BallerinaParameter.java    From product-microgateway with Apache License 2.0 5 votes vote down vote up
@Override
public BallerinaParameter buildContext(Parameter parameter, ExtendedAPI api) throws BallerinaServiceGenException {
    this.name = parameter.getName();
    this.in = parameter.getIn();
    this.description = parameter.getDescription();
    this.required = parameter.getRequired();
    this.allowEmptyValue = parameter.getAllowEmptyValue();
    return this;
}
 
Example 5
Source File: PathsProcessor.java    From swagger-parser with Apache License 2.0 5 votes vote down vote up
private void addParametersToEachOperation(PathItem pathItem) {
    if (settings.addParametersToEachOperation()) {
        List<Parameter> parameters = pathItem.getParameters();

        if (parameters != null) {
            // add parameters to each operation
            List<Operation> operations = pathItem.readOperations();
            if (operations != null) {
                for (Operation operation : operations) {
                    List<Parameter> parametersToAdd = new ArrayList<>();
                    List<Parameter> existingParameters = operation.getParameters();
                    if (existingParameters == null) {
                        existingParameters = new ArrayList<>();
                        operation.setParameters(existingParameters);
                    }
                    for (Parameter parameterToAdd : parameters) {
                        boolean matched = false;
                        for (Parameter existingParameter : existingParameters) {
                            if (parameterToAdd.getIn() != null && parameterToAdd.getIn().equals(existingParameter.getIn()) &&
                                    parameterToAdd.getName().equals(existingParameter.getName())) {
                                matched = true;
                            }
                        }
                        if (!matched) {
                            parametersToAdd.add(parameterToAdd);
                        }
                    }
                    if (parametersToAdd.size() > 0) {
                        operation.getParameters().addAll(0, parametersToAdd);
                    }
                }
            }
        }
        // remove the shared parameters
        pathItem.setParameters(null);
    }
}
 
Example 6
Source File: OpenApi3Utils.java    From vertx-web with Apache License 2.0 5 votes vote down vote up
public static String resolveStyle(Parameter param) {
  if (param.getStyle() != null) return param.getStyle().toString();
  else switch (param.getIn()) {
    case "query":
      return "form";
    case "path":
      return "simple";
    case "header":
      return "simple";
    case "cookie":
      return "form";
    default:
      return null;
  }
}
 
Example 7
Source File: DefaultGenerator.java    From openapi-generator with Apache License 2.0 4 votes vote down vote up
private static String generateParameterId(Parameter parameter) {
    return parameter.getName() + ":" + parameter.getIn();
}