Search in sources :

Example 6 with Tag

use of org.eclipse.microprofile.openapi.models.tags.Tag in project wildfly-swarm by wildfly-swarm.

the class OpenApiAnnotationScanner method processJaxRsResourceClass.

/**
 * Processing a single JAX-RS resource class (annotated with @Path).
 * @param openApi
 * @param resourceClass
 */
private void processJaxRsResourceClass(OpenAPIImpl openApi, ClassInfo resourceClass) {
    LOG.debug("Processing a JAX-RS resource class: " + resourceClass.simpleName());
    // Set the current resource path.
    AnnotationInstance pathAnno = JandexUtil.getClassAnnotation(resourceClass, OpenApiConstants.DOTNAME_PATH);
    this.currentResourcePath = pathAnno.value().asString();
    // TODO handle the use-case where the resource class extends a base class, and the base class has jax-rs relevant methods and annotations
    // Process @SecurityScheme annotations
    // //////////////////////////////////////
    List<AnnotationInstance> securitySchemeAnnotations = JandexUtil.getRepeatableAnnotation(resourceClass, OpenApiConstants.DOTNAME_SECURITY_SCHEME, OpenApiConstants.DOTNAME_SECURITY_SCHEMES);
    for (AnnotationInstance annotation : securitySchemeAnnotations) {
        String name = JandexUtil.stringValue(annotation, OpenApiConstants.PROP_SECURITY_SCHEME_NAME);
        if (name == null && JandexUtil.isRef(annotation)) {
            name = JandexUtil.nameFromRef(annotation);
        }
        if (name != null) {
            SecurityScheme securityScheme = readSecurityScheme(annotation);
            Components components = ModelUtil.components(openApi);
            components.addSecurityScheme(name, securityScheme);
        }
    }
    // Process tags (both declarations and references)
    // //////////////////////////////////////
    Set<String> tagRefs = new HashSet<>();
    AnnotationInstance tagAnno = JandexUtil.getClassAnnotation(resourceClass, OpenApiConstants.DOTNAME_TAG);
    if (tagAnno != null) {
        if (JandexUtil.isRef(tagAnno)) {
            String tagRef = JandexUtil.stringValue(tagAnno, OpenApiConstants.PROP_REF);
            tagRefs.add(tagRef);
        } else {
            Tag tag = readTag(tagAnno);
            if (tag.getName() != null) {
                openApi.addTag(tag);
                tagRefs.add(tag.getName());
            }
        }
    }
    AnnotationInstance tagsAnno = JandexUtil.getClassAnnotation(resourceClass, OpenApiConstants.DOTNAME_TAGS);
    if (tagsAnno != null) {
        AnnotationValue tagsArrayVal = tagsAnno.value();
        if (tagsArrayVal != null) {
            AnnotationInstance[] tagsArray = tagsArrayVal.asNestedArray();
            for (AnnotationInstance ta : tagsArray) {
                if (JandexUtil.isRef(ta)) {
                    String tagRef = JandexUtil.stringValue(ta, OpenApiConstants.PROP_REF);
                    tagRefs.add(tagRef);
                } else {
                    Tag tag = readTag(ta);
                    if (tag.getName() != null) {
                        openApi.addTag(tag);
                        tagRefs.add(tag.getName());
                    }
                }
            }
        }
        List<String> listValue = JandexUtil.stringListValue(tagsAnno, OpenApiConstants.PROP_REFS);
        if (listValue != null) {
            tagRefs.addAll(listValue);
        }
    }
    // //////////////////////////////////////
    for (MethodInfo methodInfo : resourceClass.methods()) {
        AnnotationInstance get = methodInfo.annotation(OpenApiConstants.DOTNAME_GET);
        if (get != null) {
            processJaxRsMethod(openApi, resourceClass, methodInfo, get, HttpMethod.GET, tagRefs);
        }
        AnnotationInstance put = methodInfo.annotation(OpenApiConstants.DOTNAME_PUT);
        if (put != null) {
            processJaxRsMethod(openApi, resourceClass, methodInfo, put, HttpMethod.PUT, tagRefs);
        }
        AnnotationInstance post = methodInfo.annotation(OpenApiConstants.DOTNAME_POST);
        if (post != null) {
            processJaxRsMethod(openApi, resourceClass, methodInfo, post, HttpMethod.POST, tagRefs);
        }
        AnnotationInstance delete = methodInfo.annotation(OpenApiConstants.DOTNAME_DELETE);
        if (delete != null) {
            processJaxRsMethod(openApi, resourceClass, methodInfo, delete, HttpMethod.DELETE, tagRefs);
        }
        AnnotationInstance head = methodInfo.annotation(OpenApiConstants.DOTNAME_HEAD);
        if (head != null) {
            processJaxRsMethod(openApi, resourceClass, methodInfo, head, HttpMethod.HEAD, tagRefs);
        }
        AnnotationInstance options = methodInfo.annotation(OpenApiConstants.DOTNAME_OPTIONS);
        if (options != null) {
            processJaxRsMethod(openApi, resourceClass, methodInfo, options, HttpMethod.OPTIONS, tagRefs);
        }
    }
}
Also used : Components(org.eclipse.microprofile.openapi.models.Components) AnnotationValue(org.jboss.jandex.AnnotationValue) MethodInfo(org.jboss.jandex.MethodInfo) Tag(org.eclipse.microprofile.openapi.models.tags.Tag) SecurityScheme(org.eclipse.microprofile.openapi.models.security.SecurityScheme) AnnotationInstance(org.jboss.jandex.AnnotationInstance) HashSet(java.util.HashSet)

Example 7 with Tag

use of org.eclipse.microprofile.openapi.models.tags.Tag in project wildfly-swarm by wildfly-swarm.

the class OpenApiParser method readTags.

/**
 * Reads a list of {@link Tag} OpenAPI nodes.
 * @param node
 */
private List<Tag> readTags(JsonNode node) {
    if (node == null || !node.isArray()) {
        return null;
    }
    ArrayNode nodes = (ArrayNode) node;
    List<Tag> rval = new ArrayList<>(nodes.size());
    for (JsonNode tagNode : nodes) {
        TagImpl model = new TagImpl();
        model.setName(JsonUtil.stringProperty(tagNode, OpenApiConstants.PROP_NAME));
        model.setDescription(JsonUtil.stringProperty(tagNode, OpenApiConstants.PROP_DESCRIPTION));
        model.setExternalDocs(readExternalDocs(tagNode.get(OpenApiConstants.PROP_EXTERNAL_DOCS)));
        readExtensions(tagNode, model);
        rval.add(model);
    }
    return rval;
}
Also used : TagImpl(org.wildfly.swarm.microprofile.openapi.api.models.tags.TagImpl) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Tag(org.eclipse.microprofile.openapi.models.tags.Tag)

Example 8 with Tag

use of org.eclipse.microprofile.openapi.models.tags.Tag in project Payara by payara.

the class ModelInvariantsTest method addKeyValueIgnoresNull.

@Test
public void addKeyValueIgnoresNull() {
    BiPredicate<Extensible<?>, String> hasExtension = (obj, key) -> obj.getExtensions().containsKey(key);
    assertAddIgnoresNull(new CallbackImpl(), Callback::addPathItem, Callback::hasPathItem);
    assertAddIgnoresNull(new CallbackImpl(), Callback::addExtension, hasExtension);
    assertAddIgnoresNull(new ExampleImpl(), Example::addExtension, hasExtension);
    assertAddIgnoresNull(new HeaderImpl(), Header::addExample, (obj, key) -> obj.getExamples().containsKey(key));
    assertAddIgnoresNull(new HeaderImpl(), Header::addExtension, hasExtension);
    assertAddIgnoresNull(new ContactImpl(), Contact::addExtension, hasExtension);
    assertAddIgnoresNull(new InfoImpl(), Info::addExtension, hasExtension);
    assertAddIgnoresNull(new LicenseImpl(), License::addExtension, hasExtension);
    assertAddIgnoresNull(new LinkImpl(), Link::addParameter, (obj, key) -> obj.getParameters().containsKey(key));
    assertAddIgnoresNull(new LinkImpl(), Link::addExtension, hasExtension);
    assertAddIgnoresNull(new ContentImpl(), Content::addMediaType, Content::hasMediaType);
    assertAddIgnoresNull(new DiscriminatorImpl(), Discriminator::addMapping, (obj, key) -> obj.getMapping().containsKey(key));
    assertAddIgnoresNull(new EncodingImpl(), Encoding::addHeader, (obj, key) -> obj.getHeaders().containsKey(key));
    assertAddIgnoresNull(new EncodingImpl(), Encoding::addExtension, hasExtension);
    assertAddIgnoresNull(new MediaTypeImpl(), MediaType::addEncoding, (obj, key) -> obj.getEncoding().containsKey(key));
    assertAddIgnoresNull(new MediaTypeImpl(), MediaType::addExample, (obj, key) -> obj.getExamples().containsKey(key));
    assertAddIgnoresNull(new MediaTypeImpl(), MediaType::addExtension, hasExtension);
    assertAddIgnoresNull(new SchemaImpl(), Schema::addProperty, (obj, key) -> obj.getProperties().containsKey(key));
    assertAddIgnoresNull(new SchemaImpl(), Schema::addExtension, hasExtension);
    assertAddIgnoresNull(new XMLImpl(), XML::addExtension, hasExtension);
    assertAddIgnoresNull(new ParameterImpl(), Parameter::addExample, (obj, key) -> obj.getExamples().containsKey(key));
    assertAddIgnoresNull(new ParameterImpl(), Parameter::addExtension, hasExtension);
    assertAddIgnoresNull(new RequestBodyImpl(), RequestBody::addExtension, hasExtension);
    assertAddIgnoresNull(new APIResponseImpl(), APIResponse::addHeader, (obj, key) -> obj.getHeaders().containsKey(key));
    assertAddIgnoresNull(new APIResponseImpl(), APIResponse::addLink, (obj, key) -> obj.getLinks().containsKey(key));
    assertAddIgnoresNull(new APIResponseImpl(), APIResponse::addExtension, hasExtension);
    assertAddIgnoresNull(new APIResponsesImpl(), APIResponses::addAPIResponse, APIResponses::hasAPIResponse);
    assertAddIgnoresNull(new APIResponsesImpl(), APIResponses::addExtension, hasExtension);
    assertAddIgnoresNull(new OAuthFlowImpl(), OAuthFlow::addExtension, hasExtension);
    assertAddIgnoresNull(new OAuthFlowsImpl(), OAuthFlows::addExtension, hasExtension);
    assertAddIgnoresNull(new SecuritySchemeImpl(), SecurityScheme::addExtension, hasExtension);
    assertAddIgnoresNull(new ServerImpl(), Server::addExtension, hasExtension);
    assertAddIgnoresNull(new ServerVariableImpl(), ServerVariable::addExtension, hasExtension);
    assertAddIgnoresNull(new TagImpl(), Tag::addExtension, hasExtension);
    assertAddIgnoresNull(new ComponentsImpl(), Components::addCallback, (obj, key) -> obj.getCallbacks().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addExample, (obj, key) -> obj.getExamples().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addHeader, (obj, key) -> obj.getHeaders().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addLink, (obj, key) -> obj.getLinks().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addParameter, (obj, key) -> obj.getParameters().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addRequestBody, (obj, key) -> obj.getRequestBodies().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addResponse, (obj, key) -> obj.getResponses().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addSchema, (obj, key) -> obj.getSchemas().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addSecurityScheme, (obj, key) -> obj.getSecuritySchemes().containsKey(key));
    assertAddIgnoresNull(new ComponentsImpl(), Components::addExtension, hasExtension);
    assertAddIgnoresNull(new ExternalDocumentationImpl(), ExternalDocumentation::addExtension, hasExtension);
    assertAddIgnoresNull(new OpenAPIImpl(), OpenAPI::addExtension, hasExtension);
    assertAddIgnoresNull(new OperationImpl(), Operation::addCallback, (obj, key) -> obj.getCallbacks().containsKey(key));
    assertAddIgnoresNull(new OperationImpl(), Operation::addExtension, hasExtension);
    assertAddIgnoresNull(new PathItemImpl(), PathItem::addExtension, hasExtension);
    assertAddIgnoresNull(new PathsImpl(), Paths::addPathItem, Paths::hasPathItem);
    assertAddIgnoresNull(new PathsImpl(), Paths::addExtension, hasExtension);
}
Also used : RequestBodyImpl(fish.payara.microprofile.openapi.impl.model.parameters.RequestBodyImpl) Components(org.eclipse.microprofile.openapi.models.Components) Discriminator(org.eclipse.microprofile.openapi.models.media.Discriminator) Info(org.eclipse.microprofile.openapi.models.info.Info) ExampleImpl(fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl) EncodingImpl(fish.payara.microprofile.openapi.impl.model.media.EncodingImpl) HeaderImpl(fish.payara.microprofile.openapi.impl.model.headers.HeaderImpl) License(org.eclipse.microprofile.openapi.models.info.License) PathItem(org.eclipse.microprofile.openapi.models.PathItem) Tag(org.eclipse.microprofile.openapi.models.tags.Tag) OAuthFlowsImpl(fish.payara.microprofile.openapi.impl.model.security.OAuthFlowsImpl) Header(org.eclipse.microprofile.openapi.models.headers.Header) MediaTypeImpl(fish.payara.microprofile.openapi.impl.model.media.MediaTypeImpl) RequestBody(org.eclipse.microprofile.openapi.models.parameters.RequestBody) SecurityScheme(org.eclipse.microprofile.openapi.models.security.SecurityScheme) Contact(org.eclipse.microprofile.openapi.models.info.Contact) OAuthFlows(org.eclipse.microprofile.openapi.models.security.OAuthFlows) OpenAPI(org.eclipse.microprofile.openapi.models.OpenAPI) List(java.util.List) ServerImpl(fish.payara.microprofile.openapi.impl.model.servers.ServerImpl) TagImpl(fish.payara.microprofile.openapi.impl.model.tags.TagImpl) APIResponseImpl(fish.payara.microprofile.openapi.impl.model.responses.APIResponseImpl) ExternalDocumentation(org.eclipse.microprofile.openapi.models.ExternalDocumentation) Assert.assertFalse(org.junit.Assert.assertFalse) SchemaImpl(fish.payara.microprofile.openapi.impl.model.media.SchemaImpl) Server(org.eclipse.microprofile.openapi.models.servers.Server) LicenseImpl(fish.payara.microprofile.openapi.impl.model.info.LicenseImpl) ContentImpl(fish.payara.microprofile.openapi.impl.model.media.ContentImpl) ServerVariableImpl(fish.payara.microprofile.openapi.impl.model.servers.ServerVariableImpl) Example(org.eclipse.microprofile.openapi.models.examples.Example) SecuritySchemeImpl(fish.payara.microprofile.openapi.impl.model.security.SecuritySchemeImpl) SecurityRequirement(org.eclipse.microprofile.openapi.models.security.SecurityRequirement) Paths(org.eclipse.microprofile.openapi.models.Paths) APIResponse(org.eclipse.microprofile.openapi.models.responses.APIResponse) MediaType(org.eclipse.microprofile.openapi.models.media.MediaType) OAuthFlow(org.eclipse.microprofile.openapi.models.security.OAuthFlow) DiscriminatorImpl(fish.payara.microprofile.openapi.impl.model.media.DiscriminatorImpl) Encoding(org.eclipse.microprofile.openapi.models.media.Encoding) ServerVariable(org.eclipse.microprofile.openapi.models.servers.ServerVariable) LinkImpl(fish.payara.microprofile.openapi.impl.model.links.LinkImpl) SecurityRequirementImpl(fish.payara.microprofile.openapi.impl.model.security.SecurityRequirementImpl) Assert.assertSame(org.junit.Assert.assertSame) BiPredicate(java.util.function.BiPredicate) InfoImpl(fish.payara.microprofile.openapi.impl.model.info.InfoImpl) Operation(org.eclipse.microprofile.openapi.models.Operation) Schema(org.eclipse.microprofile.openapi.models.media.Schema) Callback(org.eclipse.microprofile.openapi.models.callbacks.Callback) Assert.assertNotNull(org.junit.Assert.assertNotNull) Content(org.eclipse.microprofile.openapi.models.media.Content) CallbackImpl(fish.payara.microprofile.openapi.impl.model.callbacks.CallbackImpl) APIResponsesImpl(fish.payara.microprofile.openapi.impl.model.responses.APIResponsesImpl) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Link(org.eclipse.microprofile.openapi.models.links.Link) Parameter(org.eclipse.microprofile.openapi.models.parameters.Parameter) ParameterImpl(fish.payara.microprofile.openapi.impl.model.parameters.ParameterImpl) APIResponses(org.eclipse.microprofile.openapi.models.responses.APIResponses) OAuthFlowImpl(fish.payara.microprofile.openapi.impl.model.security.OAuthFlowImpl) ContactImpl(fish.payara.microprofile.openapi.impl.model.info.ContactImpl) XMLImpl(fish.payara.microprofile.openapi.impl.model.media.XMLImpl) Assert.assertEquals(org.junit.Assert.assertEquals) Extensible(org.eclipse.microprofile.openapi.models.Extensible) XML(org.eclipse.microprofile.openapi.models.media.XML) OAuthFlowsImpl(fish.payara.microprofile.openapi.impl.model.security.OAuthFlowsImpl) Server(org.eclipse.microprofile.openapi.models.servers.Server) Schema(org.eclipse.microprofile.openapi.models.media.Schema) SecuritySchemeImpl(fish.payara.microprofile.openapi.impl.model.security.SecuritySchemeImpl) License(org.eclipse.microprofile.openapi.models.info.License) ServerVariable(org.eclipse.microprofile.openapi.models.servers.ServerVariable) Components(org.eclipse.microprofile.openapi.models.Components) SchemaImpl(fish.payara.microprofile.openapi.impl.model.media.SchemaImpl) PathItem(org.eclipse.microprofile.openapi.models.PathItem) EncodingImpl(fish.payara.microprofile.openapi.impl.model.media.EncodingImpl) ExternalDocumentation(org.eclipse.microprofile.openapi.models.ExternalDocumentation) ContactImpl(fish.payara.microprofile.openapi.impl.model.info.ContactImpl) Example(org.eclipse.microprofile.openapi.models.examples.Example) MediaType(org.eclipse.microprofile.openapi.models.media.MediaType) ExampleImpl(fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl) SecurityScheme(org.eclipse.microprofile.openapi.models.security.SecurityScheme) Encoding(org.eclipse.microprofile.openapi.models.media.Encoding) RequestBodyImpl(fish.payara.microprofile.openapi.impl.model.parameters.RequestBodyImpl) ContentImpl(fish.payara.microprofile.openapi.impl.model.media.ContentImpl) Header(org.eclipse.microprofile.openapi.models.headers.Header) ParameterImpl(fish.payara.microprofile.openapi.impl.model.parameters.ParameterImpl) OAuthFlow(org.eclipse.microprofile.openapi.models.security.OAuthFlow) Content(org.eclipse.microprofile.openapi.models.media.Content) MediaTypeImpl(fish.payara.microprofile.openapi.impl.model.media.MediaTypeImpl) OpenAPI(org.eclipse.microprofile.openapi.models.OpenAPI) Link(org.eclipse.microprofile.openapi.models.links.Link) APIResponse(org.eclipse.microprofile.openapi.models.responses.APIResponse) CallbackImpl(fish.payara.microprofile.openapi.impl.model.callbacks.CallbackImpl) HeaderImpl(fish.payara.microprofile.openapi.impl.model.headers.HeaderImpl) APIResponsesImpl(fish.payara.microprofile.openapi.impl.model.responses.APIResponsesImpl) Operation(org.eclipse.microprofile.openapi.models.Operation) LicenseImpl(fish.payara.microprofile.openapi.impl.model.info.LicenseImpl) OAuthFlowImpl(fish.payara.microprofile.openapi.impl.model.security.OAuthFlowImpl) ServerImpl(fish.payara.microprofile.openapi.impl.model.servers.ServerImpl) LinkImpl(fish.payara.microprofile.openapi.impl.model.links.LinkImpl) APIResponses(org.eclipse.microprofile.openapi.models.responses.APIResponses) Paths(org.eclipse.microprofile.openapi.models.Paths) RequestBody(org.eclipse.microprofile.openapi.models.parameters.RequestBody) DiscriminatorImpl(fish.payara.microprofile.openapi.impl.model.media.DiscriminatorImpl) Extensible(org.eclipse.microprofile.openapi.models.Extensible) OAuthFlows(org.eclipse.microprofile.openapi.models.security.OAuthFlows) TagImpl(fish.payara.microprofile.openapi.impl.model.tags.TagImpl) APIResponseImpl(fish.payara.microprofile.openapi.impl.model.responses.APIResponseImpl) Info(org.eclipse.microprofile.openapi.models.info.Info) XMLImpl(fish.payara.microprofile.openapi.impl.model.media.XMLImpl) Discriminator(org.eclipse.microprofile.openapi.models.media.Discriminator) Contact(org.eclipse.microprofile.openapi.models.info.Contact) ServerVariableImpl(fish.payara.microprofile.openapi.impl.model.servers.ServerVariableImpl) Callback(org.eclipse.microprofile.openapi.models.callbacks.Callback) XML(org.eclipse.microprofile.openapi.models.media.XML) Parameter(org.eclipse.microprofile.openapi.models.parameters.Parameter) Tag(org.eclipse.microprofile.openapi.models.tags.Tag) InfoImpl(fish.payara.microprofile.openapi.impl.model.info.InfoImpl) Test(org.junit.Test)

Example 9 with Tag

use of org.eclipse.microprofile.openapi.models.tags.Tag in project Payara by payara.

the class TagImpl method merge.

public static void merge(Tag from, Operation to, boolean override, List<Tag> apiTags) {
    if (from == null) {
        return;
    }
    // If there is a reference, add the reference and return
    if (from instanceof TagImpl) {
        TagImpl fromImpl = (TagImpl) from;
        if (fromImpl.getRef() != null && !fromImpl.getRef().isEmpty()) {
            to.addTag(fromImpl.getRef());
            return;
        }
    }
    if (from.getName() != null && !from.getName().isEmpty()) {
        if (!apiTags.contains(from)) {
            // Create the new tag
            Tag newTag = new TagImpl();
            merge(from, newTag, true);
            apiTags.add(newTag);
        }
        // Reference the new tag
        to.addTag(from.getName());
    }
}
Also used : Tag(org.eclipse.microprofile.openapi.models.tags.Tag)

Example 10 with Tag

use of org.eclipse.microprofile.openapi.models.tags.Tag in project Payara by payara.

the class OpenAPIImpl method merge.

public static void merge(OpenAPI from, OpenAPI to, boolean override, ApiContext context) {
    if (from == null) {
        return;
    }
    to.setOpenapi(mergeProperty(to.getOpenapi(), from.getOpenapi(), override));
    // Handle @Info
    if (from.getInfo() != null) {
        if (to.getInfo() == null) {
            to.setInfo(new InfoImpl());
        }
        InfoImpl.merge(from.getInfo(), to.getInfo(), override);
    }
    // Handle @Servers
    if (from.getServers() != null) {
        for (Server server : from.getServers()) {
            if (server != null) {
                Server newServer = new ServerImpl();
                ServerImpl.merge(server, newServer, true);
                if (!to.getServers().contains(newServer)) {
                    to.addServer(newServer);
                }
            }
        }
    }
    // Handle @ExternalDocumentation
    if (from.getExternalDocs() != null) {
        if (to.getExternalDocs() == null) {
            to.setExternalDocs(new ExternalDocumentationImpl());
        }
        ExternalDocumentationImpl.merge(from.getExternalDocs(), to.getExternalDocs(), override);
    }
    // Handle @SecurityRequirement
    if (from.getSecurity() != null) {
        for (SecurityRequirement requirement : from.getSecurity()) {
            if (requirement != null) {
                SecurityRequirement newRequirement = new SecurityRequirementImpl();
                SecurityRequirementImpl.merge(requirement, newRequirement);
                if (!to.getSecurity().contains(newRequirement)) {
                    to.addSecurityRequirement(newRequirement);
                }
            }
        }
    }
    // Handle @Tags
    if (from.getTags() != null) {
        for (Tag tag : from.getTags()) {
            if (tag != null) {
                if (to.getTags() == null) {
                    to.setTags(createList());
                }
                Tag newTag = new TagImpl();
                TagImpl.merge(tag, newTag, override);
                to.addTag(newTag);
            }
        }
    }
    // Handle @Components
    ComponentsImpl.merge(from.getComponents(), to.getComponents(), override, context);
    PathsImpl.merge(from.getPaths(), to.getPaths(), override);
}
Also used : Server(org.eclipse.microprofile.openapi.models.servers.Server) ServerImpl(fish.payara.microprofile.openapi.impl.model.servers.ServerImpl) TagImpl(fish.payara.microprofile.openapi.impl.model.tags.TagImpl) SecurityRequirementImpl(fish.payara.microprofile.openapi.impl.model.security.SecurityRequirementImpl) Tag(org.eclipse.microprofile.openapi.models.tags.Tag) InfoImpl(fish.payara.microprofile.openapi.impl.model.info.InfoImpl) SecurityRequirement(org.eclipse.microprofile.openapi.models.security.SecurityRequirement)

Aggregations

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