All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openapi4j.parser.model.v3.ParameterUtil Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package org.openapi4j.parser.model.v3;

import org.openapi4j.core.exception.DecodeException;
import org.openapi4j.core.model.OAIContext;
import org.openapi4j.core.model.reference.Reference;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

final class ParameterUtil {
  private ParameterUtil() {
  }

  static List getIn(OAIContext context, Collection parameters, String in) {
    List inParameters = new ArrayList<>();

    if (parameters != null) {
      for (Parameter param : parameters) {
        if (param.isRef()) {
          Reference ref = context.getReferenceRegistry().getRef(param.getCanonicalRef());
          try {
            param = ref.getMappedContent(Parameter.class);
          } catch (DecodeException e) {
            // Will never happen
          }
        }

        if (param != null && in.equalsIgnoreCase(param.getIn())) {
          inParameters.add(param);
        }
      }
    }

    return inParameters;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy