Search in sources :

Example 11 with SecurityRequirement

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

the class OpenApiSerializer method writeSecurity.

/**
 * Writes the {@link SecurityRequirement} model array to the JSON tree.
 * @param parent
 * @param security
 */
private void writeSecurity(ObjectNode parent, List<SecurityRequirement> security) {
    if (security == null) {
        return;
    }
    ArrayNode array = parent.putArray(OpenApiConstants.PROP_SECURITY);
    for (SecurityRequirement securityRequirement : security) {
        ObjectNode srNode = array.addObject();
        for (String fieldName : securityRequirement.keySet()) {
            List<String> values = securityRequirement.get(fieldName);
            ArrayNode valuesNode = srNode.putArray(fieldName);
            if (values != null) {
                for (String value : values) {
                    valuesNode.add(value);
                }
            }
        }
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) 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