Search in sources :

Example 1 with SecurityRequirement

use of org.eclipse.microprofile.openapi.models.security.SecurityRequirement in project Payara by payara.

the class SecurityRequirementImpl method createInstance.

public static SecurityRequirement createInstance(AnnotationModel annotation, ApiContext context) {
    SecurityRequirement from = new SecurityRequirementImpl();
    String name = annotation.getValue("name", String.class);
    List<String> scopes = annotation.getValue("scopes", List.class);
    from.addScheme(name, scopes != null ? scopes : Collections.emptyList());
    return from;
}
Also used : SecurityRequirement(org.eclipse.microprofile.openapi.models.security.SecurityRequirement)

Example 2 with SecurityRequirement

use of org.eclipse.microprofile.openapi.models.security.SecurityRequirement in project wildfly-swarm by wildfly-swarm.

the class OpenApiSerializer method writeSecurityRequirements.

/**
 * Writes a list of {@link SecurityRequirement} to the JSON tree.
 * @param parent
 * @param models
 */
private void writeSecurityRequirements(ObjectNode parent, List<SecurityRequirement> models) {
    if (models == null) {
        return;
    }
    ArrayNode node = parent.putArray(OpenApiConstants.PROP_SECURITY);
    for (SecurityRequirement securityRequirement : models) {
        ObjectNode secNode = node.addObject();
        writeSecurityRequirementToNode(secNode, securityRequirement);
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) SecurityRequirement(org.eclipse.microprofile.openapi.models.security.SecurityRequirement)

Example 3 with SecurityRequirement

use of org.eclipse.microprofile.openapi.models.security.SecurityRequirement in project wildfly-swarm by wildfly-swarm.

the class OpenApiAnnotationScanner method readSecurity.

/**
 * Reads any SecurityRequirement annotations.  The annotation value is an array of
 * SecurityRequirement annotations.
 * @param value
 */
private List<SecurityRequirement> readSecurity(AnnotationValue securityRequirementAnnos) {
    if (securityRequirementAnnos == null) {
        return null;
    }
    LOG.debug("Processing an array of @SecurityRequirement annotations.");
    AnnotationInstance[] nestedArray = securityRequirementAnnos.asNestedArray();
    List<SecurityRequirement> requirements = new ArrayList<>();
    for (AnnotationInstance requirementAnno : nestedArray) {
        SecurityRequirement requirement = readSecurityRequirement(requirementAnno);
        if (requirement != null) {
            requirements.add(requirement);
        }
    }
    return requirements;
}
Also used : ArrayList(java.util.ArrayList) AnnotationInstance(org.jboss.jandex.AnnotationInstance) SecurityRequirement(org.eclipse.microprofile.openapi.models.security.SecurityRequirement)

Example 4 with SecurityRequirement

use of org.eclipse.microprofile.openapi.models.security.SecurityRequirement in project wildfly-swarm by wildfly-swarm.

the class OpenApiAnnotationScanner method readSecurityRequirement.

/**
 * Reads a single SecurityRequirement annotation.
 * @param annotation
 */
private SecurityRequirement readSecurityRequirement(AnnotationInstance annotation) {
    String name = JandexUtil.stringValue(annotation, OpenApiConstants.PROP_NAME);
    if (name != null) {
        List<String> scopes = JandexUtil.stringListValue(annotation, OpenApiConstants.PROP_SCOPES);
        SecurityRequirement requirement = new SecurityRequirementImpl();
        if (scopes == null) {
            requirement.addScheme(name);
        } else {
            requirement.addScheme(name, scopes);
        }
        return requirement;
    }
    return null;
}
Also used : SecurityRequirementImpl(org.wildfly.swarm.microprofile.openapi.api.models.security.SecurityRequirementImpl) SecurityRequirement(org.eclipse.microprofile.openapi.models.security.SecurityRequirement)

Example 5 with SecurityRequirement

use of org.eclipse.microprofile.openapi.models.security.SecurityRequirement in project wildfly-swarm by wildfly-swarm.

the class FilterUtil method filterSecurity.

/**
 * Filters the given model.
 * @param filter
 * @param models
 */
private static void filterSecurity(OASFilter filter, List<SecurityRequirement> models) {
    if (models == null) {
        return;
    }
    ListIterator<SecurityRequirement> iterator = models.listIterator();
    while (iterator.hasNext()) {
        SecurityRequirement model = iterator.next();
        filterSecurityRequirement(filter, model);
    }
}
Also used : SecurityRequirement(org.eclipse.microprofile.openapi.models.security.SecurityRequirement)

Aggregations

SecurityRequirement (org.eclipse.microprofile.openapi.models.security.SecurityRequirement)11 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 SecurityRequirementImpl (fish.payara.microprofile.openapi.impl.model.security.SecurityRequirementImpl)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ArrayList (java.util.ArrayList)2 Server (org.eclipse.microprofile.openapi.models.servers.Server)2 Tag (org.eclipse.microprofile.openapi.models.tags.Tag)2 AnnotationInstance (org.jboss.jandex.AnnotationInstance)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 InfoImpl (fish.payara.microprofile.openapi.impl.model.info.InfoImpl)1 ServerImpl (fish.payara.microprofile.openapi.impl.model.servers.ServerImpl)1 TagImpl (fish.payara.microprofile.openapi.impl.model.tags.TagImpl)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Operation (org.eclipse.microprofile.openapi.models.Operation)1 PathItem (org.eclipse.microprofile.openapi.models.PathItem)1 Callback (org.eclipse.microprofile.openapi.models.callbacks.Callback)1 MediaType (org.eclipse.microprofile.openapi.models.media.MediaType)1 Schema (org.eclipse.microprofile.openapi.models.media.Schema)1 Parameter (org.eclipse.microprofile.openapi.models.parameters.Parameter)1