Search in sources :

Example 1 with SecuritySchemeImpl

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

the class OpenApiParser method readSecurityScheme.

/**
 * Reads a {@link SecurityScheme} OpenAPI node.
 * @param node
 */
private SecurityScheme readSecurityScheme(JsonNode node) {
    if (node == null || !node.isObject()) {
        return null;
    }
    SecuritySchemeImpl model = new SecuritySchemeImpl();
    model.setRef(JsonUtil.stringProperty(node, OpenApiConstants.PROP_$REF));
    model.setType(readSecuritySchemeType(node.get(OpenApiConstants.PROP_TYPE)));
    model.setDescription(JsonUtil.stringProperty(node, OpenApiConstants.PROP_DESCRIPTION));
    model.setName(JsonUtil.stringProperty(node, OpenApiConstants.PROP_NAME));
    model.setIn(readSecuritySchemeIn(node.get(OpenApiConstants.PROP_IN)));
    model.setScheme(JsonUtil.stringProperty(node, OpenApiConstants.PROP_SCHEME));
    model.setBearerFormat(JsonUtil.stringProperty(node, OpenApiConstants.PROP_BEARER_FORMAT));
    model.setFlows(readOAuthFlows(node.get(OpenApiConstants.PROP_FLOWS)));
    model.setOpenIdConnectUrl(JsonUtil.stringProperty(node, OpenApiConstants.PROP_OPEN_ID_CONNECT_URL));
    readExtensions(node, model);
    return model;
}
Also used : SecuritySchemeImpl(org.wildfly.swarm.microprofile.openapi.api.models.security.SecuritySchemeImpl)

Example 2 with SecuritySchemeImpl

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

the class OpenApiAnnotationScanner method readSecurityScheme.

/**
 * Reads a SecurityScheme annotation into a model.
 * @param annotation
 */
private SecurityScheme readSecurityScheme(AnnotationInstance annotation) {
    if (annotation == null) {
        return null;
    }
    LOG.debug("Processing a single @SecurityScheme annotation.");
    SecurityScheme securityScheme = new SecuritySchemeImpl();
    securityScheme.setType(JandexUtil.enumValue(annotation, OpenApiConstants.PROP_TYPE, org.eclipse.microprofile.openapi.models.security.SecurityScheme.Type.class));
    securityScheme.setDescription(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_DESCRIPTION));
    securityScheme.setName(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_API_KEY_NAME));
    securityScheme.setIn(JandexUtil.enumValue(annotation, OpenApiConstants.PROP_IN, org.eclipse.microprofile.openapi.models.security.SecurityScheme.In.class));
    securityScheme.setScheme(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_SCHEME));
    securityScheme.setBearerFormat(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_BEARER_FORMAT));
    securityScheme.setFlows(readOAuthFlows(annotation.value(OpenApiConstants.PROP_FLOWS)));
    securityScheme.setOpenIdConnectUrl(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_OPEN_ID_CONNECT_URL));
    securityScheme.setRef(JandexUtil.refValue(annotation, RefType.SecurityScheme));
    return securityScheme;
}
Also used : ClassType(org.jboss.jandex.ClassType) RefType(org.wildfly.swarm.microprofile.openapi.runtime.util.JandexUtil.RefType) MediaType(org.eclipse.microprofile.openapi.models.media.MediaType) Type(org.jboss.jandex.Type) In(org.eclipse.microprofile.openapi.models.parameters.Parameter.In) SecuritySchemeImpl(org.wildfly.swarm.microprofile.openapi.api.models.security.SecuritySchemeImpl) SecurityScheme(org.eclipse.microprofile.openapi.models.security.SecurityScheme)

Aggregations

SecuritySchemeImpl (org.wildfly.swarm.microprofile.openapi.api.models.security.SecuritySchemeImpl)2 MediaType (org.eclipse.microprofile.openapi.models.media.MediaType)1 In (org.eclipse.microprofile.openapi.models.parameters.Parameter.In)1 SecurityScheme (org.eclipse.microprofile.openapi.models.security.SecurityScheme)1 ClassType (org.jboss.jandex.ClassType)1 Type (org.jboss.jandex.Type)1 RefType (org.wildfly.swarm.microprofile.openapi.runtime.util.JandexUtil.RefType)1