Java Code Examples for io.swagger.v3.oas.models.Components#getParameters()

The following examples show how to use io.swagger.v3.oas.models.Components#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: RefPointer.java    From openapi-diff with Apache License 2.0 6 votes vote down vote up
private Map<String, T> getMap(Components components) {
  switch (refType) {
    case REQUEST_BODIES:
      return (Map<String, T>) components.getRequestBodies();
    case RESPONSES:
      return (Map<String, T>) components.getResponses();
    case PARAMETERS:
      return (Map<String, T>) components.getParameters();
    case SCHEMAS:
      return (Map<String, T>) components.getSchemas();
    case HEADERS:
      return (Map<String, T>) components.getHeaders();
    case SECURITY_SCHEMES:
      return (Map<String, T>) components.getSecuritySchemes();
    default:
      throw new IllegalArgumentException("Not mapped for refType: " + refType);
  }
}
 
Example 2
Source File: ComponentsDocument.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
private void appendComponentsSection(Document document, Components components) {
    if (null == components) return;

    Section componentsSection = new SectionImpl(document);
    componentsSection.setTitle(labels.getLabel(SECTION_TITLE_COMPONENTS));
    String componentSectionId = "_components";
    componentsSection.setId(componentSectionId);

    appendComponentsSchemasSection(componentsSection, componentSectionId, components.getSchemas());
    Map<String, Parameter> parameters = components.getParameters();
    if (null != parameters && !parameters.isEmpty()) {
        appendSubSection(componentsSection, componentSectionId, parametersComponent, SECTION_TITLE_PARAMETERS,
                new ParametersComponent.Parameters(parameters));
    }
    Map<String, ApiResponse> responses = components.getResponses();
    if (null != responses && !responses.isEmpty()) {
        appendSubSection(componentsSection, componentSectionId, responseComponent, SECTION_TITLE_RESPONSES,
                new ResponseComponent.Parameters(responses));
    }
    Map<String, Header> headers = components.getHeaders();
    if (null != headers && !headers.isEmpty()) {
        appendSubSection(componentsSection, componentSectionId, headersComponent, SECTION_TITLE_HEADERS,
                new HeadersComponent.Parameters(headers));
    }
    Map<String, Link> links = components.getLinks();
    if (null != links && !links.isEmpty()) {
        appendSubSection(componentsSection, componentSectionId, linkComponent, SECTION_TITLE_LINKS,
                new LinkComponent.Parameters(links));
    }
    document.append(componentsSection);
}
 
Example 3
Source File: ComponentsParametersValuesValidator.java    From servicecomb-toolkit with Apache License 2.0 4 votes vote down vote up
@Override
protected Map<String, Parameter> getMapProperty(Components components) {
  return components.getParameters();
}
 
Example 4
Source File: ComponentsParametersKeysValidator.java    From servicecomb-toolkit with Apache License 2.0 4 votes vote down vote up
@Override
protected Map<String, ?> getMapProperty(Components components) {
  return components.getParameters();
}
 
Example 5
Source File: ComponentsParametersDiffValidator.java    From servicecomb-toolkit with Apache License 2.0 4 votes vote down vote up
@Override
protected Map<String, Parameter> getMapProperty(Components oasObject) {
  return oasObject.getParameters();
}
 
Example 6
Source File: ResolverFully.java    From swagger-parser with Apache License 2.0 4 votes vote down vote up
public void resolveFully(OpenAPI openAPI) {
    Components components = openAPI.getComponents();
    if (components != null && components.getRequestBodies() != null) {
        requestBodies = components.getRequestBodies();
        if (requestBodies == null) {
            requestBodies = new HashMap<>();
        }
    }

    if (components != null && components.getSchemas() != null) {
        schemas = components.getSchemas();
        if (schemas == null) {
            schemas = new HashMap<>();
        }
    }

    if (components != null && components.getExamples() != null) {
        examples = components.getExamples();
        if (examples == null) {
            examples = new HashMap<>();
        }
    }

    if (components != null && components.getHeaders() != null) {
        headers = components.getHeaders();
        if (headers == null) {
            headers = new HashMap<>();
        }
    }  

    if (components != null && components.getParameters() != null) {
        parameters = components.getParameters();
        if (parameters == null) {
            parameters = new HashMap<>();
        }
    }
    if (components != null && components.getLinks() != null) {
        links = components.getLinks();
        if (links == null) {
            links = new HashMap<>();
        }
    }
    Paths paths = openAPI.getPaths();
    if(paths != null) {
        for (String pathname : paths.keySet()) {
            PathItem pathItem = paths.get(pathname);
            resolvePath(pathItem);
        }
    }
}