Java Code Examples for io.swagger.models.Path#getParameters()

The following examples show how to use io.swagger.models.Path#getParameters() . 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: SwaggerInventory.java    From swagger-parser with Apache License 2.0 6 votes vote down vote up
public void process(Path path) {
    this.paths.add(path);
    Iterator var2;
    if(path.getParameters() != null) {
        var2 = path.getParameters().iterator();

        while(var2.hasNext()) {
            Parameter operation = (Parameter)var2.next();
            this.process(operation);
        }
    }

    if(path.getOperations() != null) {
        var2 = path.getOperations().iterator();

        while(var2.hasNext()) {
            Operation operation1 = (Operation)var2.next();
            this.process(operation1);
        }
    }

}
 
Example 2
Source File: ProtoApiFromOpenApi.java    From api-compiler with Apache License 2.0 5 votes vote down vote up
/**
 * Returns all parameters for the operation. Note: According to the spec, parameters defined
 * inside the operations overrides the parameters defined in the path scope which has the same
 * name and location values (example name : 'shelveId' and location : 'query').
 */
public static ImmutableList<Parameter> getAllResolvedParameters(
    Operation operation, Path parentPath, final DiagCollector diagCollector, Location location) {
  List<Parameter> allResolvedParameters = new ArrayList<>();
  // First populate all the parameters defined in the operation.
  if (operation.getParameters() != null) {
    ImmutableList<Parameter> resolvedParameters =
        getResolvedParameters(
            diagCollector, ImmutableList.copyOf(operation.getParameters()), location);
    allResolvedParameters.addAll(resolvedParameters);
  }
  FluentIterable<Parameter> fluentAllParameters = FluentIterable.from(allResolvedParameters);

  // Now populate shared parameters that were not overridden inside the operation.
  if (parentPath.getParameters() != null) {
    ImmutableList<Parameter> resolvedSharedParameters =
        getResolvedParameters(
            diagCollector, ImmutableList.copyOf(parentPath.getParameters()), location);
    for (final Parameter sharedParam : resolvedSharedParameters) {
      boolean overriddenInOperation =
          fluentAllParameters.anyMatch(
              new Predicate<Parameter>() {
                @Override
                public boolean apply(Parameter parameter) {
                  return parameter.getName().equals(sharedParam.getName())
                      && parameter.getIn().equals(sharedParam.getIn());
                }
              });
      if (!overriddenInOperation) {
        allResolvedParameters.add(sharedParam);
      }
    }
  }
  return ImmutableList.copyOf(allResolvedParameters);
}
 
Example 3
Source File: SwaggerConverter.java    From swagger-parser with Apache License 2.0 4 votes vote down vote up
public PathItem convert(Path v2Path) {
    PathItem v3Path = new PathItem();

    if (v2Path instanceof RefPath) {

        v3Path.set$ref(((RefPath) v2Path).get$ref());
    } else {

        if (v2Path.getParameters() != null) {
            for (io.swagger.models.parameters.Parameter param : v2Path.getParameters()) {
                v3Path.addParametersItem(convert(param));
            }
        }

        io.swagger.models.Operation v2Operation;

        v2Operation = v2Path.getGet();
        if (v2Operation != null) {
            v3Path.setGet(convert(v2Operation));
        }
        v2Operation = v2Path.getPut();
        if (v2Operation != null) {
            v3Path.setPut(convert(v2Operation));
        }
        v2Operation = v2Path.getPost();
        if (v2Operation != null) {
            v3Path.setPost(convert(v2Operation));
        }
        v2Operation = v2Path.getPatch();
        if (v2Operation != null) {
            v3Path.setPatch(convert(v2Operation));
        }
        v2Operation = v2Path.getDelete();
        if (v2Operation != null) {
            v3Path.setDelete(convert(v2Operation));
        }
        v2Operation = v2Path.getHead();
        if (v2Operation != null) {
            v3Path.setHead(convert(v2Operation));
        }
        v2Operation = v2Path.getOptions();
        if (v2Operation != null) {
            v3Path.setOptions(convert(v2Operation));
        }

        v3Path.setExtensions(convert(v2Path.getVendorExtensions()));
    }

    return v3Path;
}