Search in sources :

Example 1 with ComponentsImpl

use of org.wildfly.swarm.microprofile.openapi.api.models.ComponentsImpl in project wildfly-swarm by wildfly-swarm.

the class OpenApiParser method readComponents.

/**
 * Reads the {@link Components} OpenAPI nodes.
 * @param node
 */
private Components readComponents(JsonNode node) {
    if (node == null || !node.isObject()) {
        return null;
    }
    ComponentsImpl model = new ComponentsImpl();
    model.setSchemas(readSchemas(node.get(OpenApiConstants.PROP_SCHEMAS)));
    model.setResponses(readResponses(node.get(OpenApiConstants.PROP_RESPONSES)));
    model.setParameters(readParameters(node.get(OpenApiConstants.PROP_PARAMETERS)));
    model.setExamples(readExamples(node.get(OpenApiConstants.PROP_EXAMPLES)));
    model.setRequestBodies(readRequestBodies(node.get(OpenApiConstants.PROP_REQUEST_BODIES)));
    model.setHeaders(readHeaders(node.get(OpenApiConstants.PROP_HEADERS)));
    model.setSecuritySchemes(readSecuritySchemes(node.get(OpenApiConstants.PROP_SECURITY_SCHEMES)));
    model.setLinks(readLinks(node.get(OpenApiConstants.PROP_LINKS)));
    model.setCallbacks(readCallbacks(node.get(OpenApiConstants.PROP_CALLBACKS)));
    readExtensions(node, model);
    return model;
}
Also used : ComponentsImpl(org.wildfly.swarm.microprofile.openapi.api.models.ComponentsImpl)

Example 2 with ComponentsImpl

use of org.wildfly.swarm.microprofile.openapi.api.models.ComponentsImpl in project wildfly-swarm by wildfly-swarm.

the class OpenApiDataObjectScannerTestBase method schemaToString.

public static String schemaToString(String entityName, Schema schema) throws IOException {
    Map<String, Schema> map = new HashMap<>();
    map.put(entityName, schema);
    OpenAPIImpl oai = new OpenAPIImpl();
    ComponentsImpl comp = new ComponentsImpl();
    comp.setSchemas(map);
    oai.setComponents(comp);
    return OpenApiSerializer.serialize(oai, OpenApiSerializer.Format.JSON);
}
Also used : HashMap(java.util.HashMap) OpenAPIImpl(org.wildfly.swarm.microprofile.openapi.api.models.OpenAPIImpl) Schema(org.eclipse.microprofile.openapi.models.media.Schema) ComponentsImpl(org.wildfly.swarm.microprofile.openapi.api.models.ComponentsImpl)

Example 3 with ComponentsImpl

use of org.wildfly.swarm.microprofile.openapi.api.models.ComponentsImpl in project wildfly-swarm by wildfly-swarm.

the class OpenApiAnnotationScanner method readComponents.

/**
 * Reads any Components annotations.
 * @param componentsAnno
 */
private Components readComponents(AnnotationValue componentsAnno) {
    if (componentsAnno == null) {
        return null;
    }
    LOG.debug("Processing an @Components annotation.");
    AnnotationInstance nested = componentsAnno.asNested();
    Components components = new ComponentsImpl();
    // TODO for EVERY item below, handle the case where the annotation is ref-only.  then strip the ref path and use the final segment as the name
    components.setCallbacks(readCallbacks(nested.value(OpenApiConstants.PROP_CALLBACKS)));
    components.setExamples(readExamples(nested.value(OpenApiConstants.PROP_EXAMPLES)));
    components.setHeaders(readHeaders(nested.value(OpenApiConstants.PROP_HEADERS)));
    components.setLinks(readLinks(nested.value(OpenApiConstants.PROP_LINKS)));
    components.setParameters(readParameters(nested.value(OpenApiConstants.PROP_PARAMETERS)));
    components.setRequestBodies(readRequestBodies(nested.value(OpenApiConstants.PROP_REQUEST_BODIES)));
    components.setResponses(readResponses(nested.value(OpenApiConstants.PROP_RESPONSES)));
    components.setSchemas(readSchemas(nested.value(OpenApiConstants.PROP_SCHEMAS)));
    components.setSecuritySchemes(readSecuritySchemes(nested.value(OpenApiConstants.PROP_SECURITY_SCHEMES)));
    return components;
}
Also used : Components(org.eclipse.microprofile.openapi.models.Components) ComponentsImpl(org.wildfly.swarm.microprofile.openapi.api.models.ComponentsImpl) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Aggregations

ComponentsImpl (org.wildfly.swarm.microprofile.openapi.api.models.ComponentsImpl)3 HashMap (java.util.HashMap)1 Components (org.eclipse.microprofile.openapi.models.Components)1 Schema (org.eclipse.microprofile.openapi.models.media.Schema)1 AnnotationInstance (org.jboss.jandex.AnnotationInstance)1 OpenAPIImpl (org.wildfly.swarm.microprofile.openapi.api.models.OpenAPIImpl)1