Search in sources :

Example 1 with ExampleImpl

use of fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl in project Payara by payara.

the class ParameterImpl method merge.

public static void merge(Parameter from, Parameter to, boolean override, ApiContext context) {
    if (from == null) {
        return;
    }
    if (from.getRef() != null && !from.getRef().isEmpty()) {
        applyReference(to, from.getRef());
        return;
    }
    to.setName(mergeProperty(to.getName(), from.getName(), override));
    to.setDescription(mergeProperty(to.getDescription(), from.getDescription(), override));
    if (from.getIn() != null) {
        to.setIn(mergeProperty(to.getIn(), from.getIn(), override));
    }
    to.setRequired(mergeProperty(to.getRequired(), from.getRequired(), override));
    to.setDeprecated(mergeProperty(to.getDeprecated(), from.getDeprecated(), override));
    to.setAllowEmptyValue(mergeProperty(to.getAllowEmptyValue(), from.getAllowEmptyValue(), override));
    if (from.getStyle() != null) {
        to.setStyle(mergeProperty(to.getStyle(), from.getStyle(), override));
    }
    if (from.getExplode() != null) {
        to.setExplode(mergeProperty(to.getExplode(), false, override));
    }
    to.setAllowReserved(mergeProperty(to.getAllowReserved(), from.getAllowReserved(), override));
    if (from.getSchema() != null) {
        if (to.getSchema() == null) {
            to.setSchema(new SchemaImpl());
        }
        SchemaImpl.merge(from.getSchema(), to.getSchema(), override, context);
    }
    to.setExample(mergeProperty(to.getExample(), from.getExample(), override));
    if (from.getExamples() != null) {
        for (String exampleName : from.getExamples().keySet()) {
            if (exampleName != null) {
                Example example = new ExampleImpl();
                ExampleImpl.merge(from.getExamples().get(exampleName), example, override);
                to.addExample(exampleName, example);
            }
        }
    }
    if (from instanceof ParameterImpl) {
        ParameterImpl fromImpl = (ParameterImpl) from;
        if (fromImpl.getContents() != null) {
            if (to.getContent() == null) {
                to.setContent(new ContentImpl());
            }
            for (ContentImpl content : fromImpl.getContents()) {
                ContentImpl.merge(content, to.getContent(), override, context);
            }
        }
    }
    if (from.getContent() != null) {
        if (to.getContent() == null) {
            to.setContent(new ContentImpl());
        }
        ContentImpl.merge((ContentImpl) from.getContent(), to.getContent(), override, context);
    }
}
Also used : SchemaImpl(fish.payara.microprofile.openapi.impl.model.media.SchemaImpl) Example(org.eclipse.microprofile.openapi.models.examples.Example) ContentImpl(fish.payara.microprofile.openapi.impl.model.media.ContentImpl) ExampleImpl(fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl)

Example 2 with ExampleImpl

use of fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl in project Payara by payara.

the class ParameterImpl method createInstance.

public static Parameter createInstance(AnnotationModel annotation, ApiContext context) {
    ParameterImpl from = new ParameterImpl();
    from.setName(annotation.getValue("name", String.class));
    EnumModel inEnum = annotation.getValue("in", EnumModel.class);
    if (inEnum != null) {
        from.setIn(In.valueOf(inEnum.getValue()));
    }
    from.setDescription(annotation.getValue("description", String.class));
    from.setRequired(annotation.getValue("required", Boolean.class));
    from.setDeprecated(annotation.getValue("deprecated", Boolean.class));
    from.setAllowEmptyValue(annotation.getValue("allowEmptyValue", Boolean.class));
    String ref = annotation.getValue("ref", String.class);
    if (ref != null && !ref.isEmpty()) {
        from.setRef(ref);
    }
    EnumModel styleEnum = annotation.getValue("style", EnumModel.class);
    if (styleEnum != null) {
        from.setStyle(Style.valueOf(styleEnum.getValue()));
    }
    from.setExplode(annotation.getValue("explode", Boolean.class));
    from.setAllowReserved(annotation.getValue("allowReserved", Boolean.class));
    AnnotationModel schemaAnnotation = annotation.getValue("schema", AnnotationModel.class);
    if (schemaAnnotation != null) {
        Boolean hidden = schemaAnnotation.getValue("hidden", Boolean.class);
        if (hidden == null || !hidden) {
            from.setSchema(SchemaImpl.createInstance(schemaAnnotation, context));
        }
    }
    extractAnnotations(annotation, context, "examples", "name", ExampleImpl::createInstance, from::addExample);
    from.setExample(annotation.getValue("example", Object.class));
    final List<ContentImpl> contents = createList();
    extractAnnotations(annotation, context, "content", ContentImpl::createInstance, contents::add);
    for (ContentImpl content : contents) {
        content.getMediaTypes().forEach(from.content::addMediaType);
    }
    return from;
}
Also used : EnumModel(org.glassfish.hk2.classmodel.reflect.EnumModel) AnnotationModel(org.glassfish.hk2.classmodel.reflect.AnnotationModel) ContentImpl(fish.payara.microprofile.openapi.impl.model.media.ContentImpl) ExampleImpl(fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl)

Example 3 with ExampleImpl

use of fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl in project Payara by payara.

the class ComponentsImpl method merge.

public static void merge(Components from, Components to, boolean override, ApiContext context) {
    if (from == null) {
        return;
    }
    // Handle @Schema
    if (from.getSchemas() != null) {
        for (Entry<String, Schema> fromEntry : from.getSchemas().entrySet()) {
            final String schemaName = fromEntry.getKey();
            if (schemaName != null) {
                final Schema fromSchema = fromEntry.getValue();
                final Schema toSchema = to.getSchemas().getOrDefault(schemaName, new SchemaImpl());
                SchemaImpl.merge(fromSchema, toSchema, override, context);
                to.addSchema(schemaName, toSchema);
            }
        }
    }
    // Handle @Callback
    if (from.getCallbacks() != null) {
        for (String callbackName : from.getCallbacks().keySet()) {
            if (callbackName != null) {
                Callback newCallback = new CallbackImpl();
                CallbackImpl.merge(from.getCallbacks().get(callbackName), newCallback, override, context);
                to.addCallback(callbackName, newCallback);
            }
        }
    }
    // Handle @ExampleObject
    if (from.getExamples() != null) {
        for (String exampleName : from.getExamples().keySet()) {
            if (exampleName != null) {
                Example newExample = new ExampleImpl();
                ExampleImpl.merge(from.getExamples().get(exampleName), newExample, override);
                to.addExample(exampleName, newExample);
            }
        }
    }
    // Handle @Header
    if (from.getHeaders() != null) {
        for (String headerName : from.getHeaders().keySet()) {
            if (headerName != null) {
                Header newHeader = new HeaderImpl();
                HeaderImpl.merge(from.getHeaders().get(headerName), newHeader, override, context);
                to.addHeader(headerName, newHeader);
            }
        }
    }
    // Handle @Link
    if (from.getLinks() != null) {
        for (String linkName : from.getLinks().keySet()) {
            if (linkName != null) {
                Link newLink = new LinkImpl();
                LinkImpl.merge(from.getLinks().get(linkName), newLink, override);
                to.addLink(linkName, newLink);
            }
        }
    }
    // Handle @Parameter
    if (from.getParameters() != null) {
        for (String parameterName : from.getParameters().keySet()) {
            if (parameterName != null) {
                Parameter newParameter = new ParameterImpl();
                ParameterImpl.merge(from.getParameters().get(parameterName), newParameter, override, context);
                to.addParameter(parameterName, newParameter);
            }
        }
    }
    // Handle @RequestBody
    if (from.getRequestBodies() != null) {
        for (String requestBodyName : from.getRequestBodies().keySet()) {
            if (requestBodyName != null) {
                RequestBody newRequestBody = new RequestBodyImpl();
                RequestBodyImpl.merge(from.getRequestBodies().get(requestBodyName), newRequestBody, override, context);
                to.addRequestBody(requestBodyName, newRequestBody);
            }
        }
    }
    // Handle @APIResponse
    if (from.getResponses() != null) {
        for (String responseName : from.getResponses().keySet()) {
            if (responseName != null) {
                APIResponse newResponse = new APIResponseImpl();
                APIResponseImpl.merge(from.getResponses().get(responseName), newResponse, override, context);
                to.addResponse(responseName, newResponse);
            }
        }
    }
    // Handle @SecurityScheme
    if (from.getSecuritySchemes() != null) {
        for (String securitySchemeName : from.getSecuritySchemes().keySet()) {
            if (securitySchemeName != null) {
                SecurityScheme newSecurity = new SecuritySchemeImpl();
                SecuritySchemeImpl.merge(from.getSecuritySchemes().get(securitySchemeName), newSecurity, override);
                to.addSecurityScheme(securitySchemeName, newSecurity);
            }
        }
    }
}
Also used : 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) Schema(org.eclipse.microprofile.openapi.models.media.Schema) SecuritySchemeImpl(fish.payara.microprofile.openapi.impl.model.security.SecuritySchemeImpl) RequestBodyImpl(fish.payara.microprofile.openapi.impl.model.parameters.RequestBodyImpl) APIResponseImpl(fish.payara.microprofile.openapi.impl.model.responses.APIResponseImpl) SchemaImpl(fish.payara.microprofile.openapi.impl.model.media.SchemaImpl) Callback(org.eclipse.microprofile.openapi.models.callbacks.Callback) Header(org.eclipse.microprofile.openapi.models.headers.Header) ParameterImpl(fish.payara.microprofile.openapi.impl.model.parameters.ParameterImpl) Example(org.eclipse.microprofile.openapi.models.examples.Example) LinkImpl(fish.payara.microprofile.openapi.impl.model.links.LinkImpl) Parameter(org.eclipse.microprofile.openapi.models.parameters.Parameter) ExampleImpl(fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl) SecurityScheme(org.eclipse.microprofile.openapi.models.security.SecurityScheme) Link(org.eclipse.microprofile.openapi.models.links.Link) RequestBody(org.eclipse.microprofile.openapi.models.parameters.RequestBody)

Example 4 with ExampleImpl

use of fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl 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 5 with ExampleImpl

use of fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl in project Payara by payara.

the class ComponentsImpl method createInstance.

public static Components createInstance(AnnotationModel annotation, ApiContext context) {
    Components from = new ComponentsImpl();
    extractAnnotations(annotation, context, "schemas", "name", SchemaImpl::createInstance, from::addSchema);
    extractAnnotations(annotation, context, "responses", "name", APIResponseImpl::createInstance, from::addResponse);
    extractAnnotations(annotation, context, "parameters", "name", ParameterImpl::createInstance, from::addParameter);
    extractAnnotations(annotation, context, "examples", "name", ExampleImpl::createInstance, from::addExample);
    extractAnnotations(annotation, context, "requestBodies", "name", RequestBodyImpl::createInstance, from::addRequestBody);
    extractAnnotations(annotation, context, "securitySchemes", "securitySchemeName", SecuritySchemeImpl::createInstance, from::addSecurityScheme);
    extractAnnotations(annotation, context, "links", "name", LinkImpl::createInstance, from::addLink);
    extractAnnotations(annotation, context, "callbacks", "name", CallbackImpl::createInstance, from::addCallback);
    HeaderImpl.createInstances(annotation, context).forEach(from::addHeader);
    return from;
}
Also used : Components(org.eclipse.microprofile.openapi.models.Components) SchemaImpl(fish.payara.microprofile.openapi.impl.model.media.SchemaImpl) CallbackImpl(fish.payara.microprofile.openapi.impl.model.callbacks.CallbackImpl) ParameterImpl(fish.payara.microprofile.openapi.impl.model.parameters.ParameterImpl) SecuritySchemeImpl(fish.payara.microprofile.openapi.impl.model.security.SecuritySchemeImpl) LinkImpl(fish.payara.microprofile.openapi.impl.model.links.LinkImpl) APIResponseImpl(fish.payara.microprofile.openapi.impl.model.responses.APIResponseImpl) RequestBodyImpl(fish.payara.microprofile.openapi.impl.model.parameters.RequestBodyImpl) ExampleImpl(fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl)

Aggregations

ExampleImpl (fish.payara.microprofile.openapi.impl.model.examples.ExampleImpl)8 ContentImpl (fish.payara.microprofile.openapi.impl.model.media.ContentImpl)5 SchemaImpl (fish.payara.microprofile.openapi.impl.model.media.SchemaImpl)5 Example (org.eclipse.microprofile.openapi.models.examples.Example)4 CallbackImpl (fish.payara.microprofile.openapi.impl.model.callbacks.CallbackImpl)3 LinkImpl (fish.payara.microprofile.openapi.impl.model.links.LinkImpl)3 ParameterImpl (fish.payara.microprofile.openapi.impl.model.parameters.ParameterImpl)3 RequestBodyImpl (fish.payara.microprofile.openapi.impl.model.parameters.RequestBodyImpl)3 APIResponseImpl (fish.payara.microprofile.openapi.impl.model.responses.APIResponseImpl)3 SecuritySchemeImpl (fish.payara.microprofile.openapi.impl.model.security.SecuritySchemeImpl)3 AnnotationModel (org.glassfish.hk2.classmodel.reflect.AnnotationModel)3 HeaderImpl (fish.payara.microprofile.openapi.impl.model.headers.HeaderImpl)2 Components (org.eclipse.microprofile.openapi.models.Components)2 Callback (org.eclipse.microprofile.openapi.models.callbacks.Callback)2 Header (org.eclipse.microprofile.openapi.models.headers.Header)2 MediaType (org.eclipse.microprofile.openapi.models.media.MediaType)2 ContactImpl (fish.payara.microprofile.openapi.impl.model.info.ContactImpl)1 InfoImpl (fish.payara.microprofile.openapi.impl.model.info.InfoImpl)1 LicenseImpl (fish.payara.microprofile.openapi.impl.model.info.LicenseImpl)1 DiscriminatorImpl (fish.payara.microprofile.openapi.impl.model.media.DiscriminatorImpl)1