Search in sources :

Example 31 with Callback

use of io.swagger.v3.oas.annotations.callbacks.Callback in project convertigo by convertigo.

the class OpenApiUtils method parse.

@SuppressWarnings("rawtypes")
public static OpenAPI parse(String requestUrl, Collection<UrlMapper> collection) {
    OpenAPI openAPI = parseCommon(requestUrl, null);
    List<Tag> tags = new ArrayList<>();
    Components components = new Components();
    components.callbacks(new HashMap<String, Callback>());
    components.examples(new HashMap<String, Example>());
    components.extensions(new HashMap<String, Object>());
    components.headers(new HashMap<String, Header>());
    components.links(new HashMap<String, Link>());
    components.parameters(new HashMap<String, Parameter>());
    components.requestBodies(new HashMap<String, RequestBody>());
    components.responses(new HashMap<String, ApiResponse>());
    components.schemas(new HashMap<String, Schema>());
    components.securitySchemes(new HashMap<String, SecurityScheme>());
    Paths paths = new Paths();
    for (UrlMapper urlMapper : collection) {
        if (urlMapper != null) {
            OpenAPI _openAPI = parse(requestUrl, urlMapper);
            if (_openAPI != null) {
                try {
                    tags.addAll(_openAPI.getTags());
                } catch (Exception e) {
                }
                try {
                    paths.putAll(_openAPI.getPaths());
                } catch (Exception e) {
                }
                Components _components = _openAPI.getComponents();
                if (_components != null) {
                    try {
                        components.getCallbacks().putAll(_components.getCallbacks());
                    } catch (Exception e) {
                    }
                    try {
                        components.getExamples().putAll(_components.getExamples());
                    } catch (Exception e) {
                    }
                    try {
                        components.getExtensions().putAll(_components.getExtensions());
                    } catch (Exception e) {
                    }
                    try {
                        components.getHeaders().putAll(_components.getHeaders());
                    } catch (Exception e) {
                    }
                    try {
                        components.getLinks().putAll(_components.getLinks());
                    } catch (Exception e) {
                    }
                    try {
                        components.getParameters().putAll(_components.getParameters());
                    } catch (Exception e) {
                    }
                    try {
                        components.getRequestBodies().putAll(_components.getRequestBodies());
                    } catch (Exception e) {
                    }
                    try {
                        components.getResponses().putAll(_components.getResponses());
                    } catch (Exception e) {
                    }
                    try {
                        components.getSchemas().putAll(_components.getSchemas());
                    } catch (Exception e) {
                    }
                    try {
                        components.getSecuritySchemes().putAll(_components.getSecuritySchemes());
                    } catch (Exception e) {
                    }
                }
            }
        }
    }
    openAPI.setTags(tags);
    openAPI.setPaths(paths);
    openAPI.setComponents(components);
    return openAPI;
}
Also used : IntegerSchema(io.swagger.v3.oas.models.media.IntegerSchema) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) FileSchema(io.swagger.v3.oas.models.media.FileSchema) BooleanSchema(io.swagger.v3.oas.models.media.BooleanSchema) StringSchema(io.swagger.v3.oas.models.media.StringSchema) ObjectSchema(io.swagger.v3.oas.models.media.ObjectSchema) NumberSchema(io.swagger.v3.oas.models.media.NumberSchema) XmlSchema(org.apache.ws.commons.schema.XmlSchema) Schema(io.swagger.v3.oas.models.media.Schema) ArrayList(java.util.ArrayList) ApiResponse(io.swagger.v3.oas.models.responses.ApiResponse) Components(io.swagger.v3.oas.models.Components) Example(io.swagger.v3.oas.models.examples.Example) Paths(io.swagger.v3.oas.models.Paths) SecurityScheme(io.swagger.v3.oas.models.security.SecurityScheme) RequestBody(io.swagger.v3.oas.models.parameters.RequestBody) UrlMapper(com.twinsoft.convertigo.beans.core.UrlMapper) JSONException(org.codehaus.jettison.json.JSONException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Callback(io.swagger.v3.oas.models.callbacks.Callback) Header(io.swagger.v3.oas.models.headers.Header) HeaderParameter(io.swagger.v3.oas.models.parameters.HeaderParameter) PathParameter(io.swagger.v3.oas.models.parameters.PathParameter) LinkParameter(io.swagger.v3.oas.models.links.LinkParameter) Parameter(io.swagger.v3.oas.models.parameters.Parameter) QueryParameter(io.swagger.v3.oas.models.parameters.QueryParameter) UrlMappingParameter(com.twinsoft.convertigo.beans.core.UrlMappingParameter) JSONObject(org.codehaus.jettison.json.JSONObject) Tag(io.swagger.v3.oas.models.tags.Tag) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Link(io.swagger.v3.oas.models.links.Link)

Aggregations

Callback (io.swagger.v3.oas.models.callbacks.Callback)19 Operation (io.swagger.v3.oas.models.Operation)13 PathItem (io.swagger.v3.oas.models.PathItem)13 OpenAPI (io.swagger.v3.oas.models.OpenAPI)12 Parameter (io.swagger.v3.oas.models.parameters.Parameter)9 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)9 Test (org.testng.annotations.Test)9 Components (io.swagger.v3.oas.models.Components)7 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)6 Schema (io.swagger.v3.oas.models.media.Schema)6 RequestBody (io.swagger.v3.oas.models.parameters.RequestBody)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 Operation (io.swagger.v3.oas.annotations.Operation)4 Example (io.swagger.v3.oas.models.examples.Example)4 Link (io.swagger.v3.oas.models.links.Link)4 StringSchema (io.swagger.v3.oas.models.media.StringSchema)4 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)4 SecurityScheme (io.swagger.v3.oas.models.security.SecurityScheme)4 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4