use of fish.payara.microprofile.openapi.impl.model.servers.ServerImpl in project Payara by payara.
the class OpenAPIImpl method createInstance.
public static OpenAPI createInstance(AnnotationModel annotation, ApiContext context) {
OpenAPIImpl from = new OpenAPIImpl();
from.context = context;
AnnotationModel info = annotation.getValue("info", AnnotationModel.class);
if (info != null) {
from.setInfo(InfoImpl.createInstance(info));
}
AnnotationModel externalDocs = annotation.getValue("externalDocs", AnnotationModel.class);
if (externalDocs != null) {
from.setExternalDocs(ExternalDocumentationImpl.createInstance(externalDocs));
}
extractAnnotations(annotation, context, "security", SecurityRequirementImpl::createInstance, from::addSecurityRequirement);
extractAnnotations(annotation, context, "servers", ServerImpl::createInstance, from::addServer);
extractAnnotations(annotation, context, "tags", TagImpl::createInstance, from::addTag);
AnnotationModel components = annotation.getValue("components", AnnotationModel.class);
if (components != null) {
from.setComponents(ComponentsImpl.createInstance(components, context));
}
return from;
}
use of fish.payara.microprofile.openapi.impl.model.servers.ServerImpl in project Payara by payara.
the class PathItemImpl method createInstance.
public static PathItem createInstance(AnnotationModel annotation, ApiContext context) {
PathItem from = new PathItemImpl();
extractAnnotations(annotation, context, "servers", ServerImpl::createInstance, from::addServer);
return from;
}
use of fish.payara.microprofile.openapi.impl.model.servers.ServerImpl in project Payara by payara.
the class OperationImpl method createInstance.
public static Operation createInstance(AnnotationModel annotation, ApiContext context) {
OperationImpl from = new OperationImpl();
from.setSummary(annotation.getValue("summary", String.class));
from.setDescription(annotation.getValue("description", String.class));
AnnotationModel externalDocs = annotation.getValue("externalDocs", AnnotationModel.class);
if (externalDocs != null) {
from.setExternalDocs(ExternalDocumentationImpl.createInstance(externalDocs));
}
from.setOperationId(annotation.getValue("operationId", String.class));
extractAnnotations(annotation, context, "parameters", ParameterImpl::createInstance, from::addParameter);
AnnotationModel requestBody = annotation.getValue("requestBody", AnnotationModel.class);
if (requestBody != null) {
from.setRequestBody(RequestBodyImpl.createInstance(requestBody, context));
}
extractAnnotations(annotation, context, "responses", "responseCode", APIResponseImpl::createInstance, from.responses::addAPIResponse);
extractAnnotations(annotation, context, "callbacks", "name", CallbackImpl::createInstance, from::addCallback);
from.setDeprecated(annotation.getValue("deprecated", Boolean.class));
extractAnnotations(annotation, context, "security", SecurityRequirementImpl::createInstance, from::addSecurityRequirement);
extractAnnotations(annotation, context, "servers", ServerImpl::createInstance, from::addServer);
from.setMethod(annotation.getValue("method", String.class));
return from;
}
use of fish.payara.microprofile.openapi.impl.model.servers.ServerImpl in project Payara by payara.
the class ServersBuilderTest method serverIsInitialisedCorrectly.
@Test
public void serverIsInitialisedCorrectly() {
Server server = new ServerImpl();
assertNotNull("server variables are null", server.getVariables());
}
use of fish.payara.microprofile.openapi.impl.model.servers.ServerImpl 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);
}
Aggregations