use of org.wildfly.swarm.microprofile.openapi.api.models.info.InfoImpl in project wildfly-swarm by wildfly-swarm.
the class OpenApiDocument method initialize.
public void initialize() {
synchronized (INSTANCE) {
if (model != null) {
modelAlreadyInitialized();
}
// Check all the required parts are set
if (config == null) {
throw new IllegalStateException("OpenApiConfig must be set before init");
}
// Phase 1: Use OASModelReader
OpenAPI merged = readerModel;
// Phase 2: Merge any static OpenAPI file packaged in the app
merged = MergeUtil.mergeObjects(merged, staticFileModel);
// Phase 3: Merge annotations
merged = MergeUtil.mergeObjects(merged, annotationsModel);
// Phase 4: Filter model via OASFilter
merged = filterModel(merged);
// Phase 5: Default empty document if model == null
if (merged == null) {
merged = new OpenAPIImpl();
merged.setOpenapi(OpenApiConstants.OPEN_API_VERSION);
}
// Phase 6: Provide missing required elements
if (merged.getPaths() == null) {
merged.setPaths(new PathsImpl());
}
if (merged.getInfo() == null) {
merged.setInfo(new InfoImpl());
}
if (merged.getInfo().getTitle() == null) {
merged.getInfo().setTitle((archiveName == null ? "Generated" : archiveName) + " API");
}
if (merged.getInfo().getVersion() == null) {
merged.getInfo().setVersion("1.0");
}
// Phase 7: Use Config values to add Servers (global, pathItem, operation)
ServersUtil.configureServers(config, merged);
model = merged;
LOGGER.info("OpenAPI document initialized: " + model);
clear();
}
}
use of org.wildfly.swarm.microprofile.openapi.api.models.info.InfoImpl in project wildfly-swarm by wildfly-swarm.
the class OpenApiAnnotationScanner method readInfo.
/**
* Reads an Info annotation.
* @param infoAnno
*/
private Info readInfo(AnnotationValue infoAnno) {
if (infoAnno == null) {
return null;
}
LOG.debug("Processing an @Info annotation.");
AnnotationInstance nested = infoAnno.asNested();
InfoImpl info = new InfoImpl();
info.setTitle(JandexUtil.stringValue(nested, OpenApiConstants.PROP_TITLE));
info.setDescription(JandexUtil.stringValue(nested, OpenApiConstants.PROP_DESCRIPTION));
info.setTermsOfService(JandexUtil.stringValue(nested, OpenApiConstants.PROP_TERMS_OF_SERVICE));
info.setContact(readContact(nested.value(OpenApiConstants.PROP_CONTACT)));
info.setLicense(readLicense(nested.value(OpenApiConstants.PROP_LICENSE)));
info.setVersion(JandexUtil.stringValue(nested, OpenApiConstants.PROP_VERSION));
return info;
}
use of org.wildfly.swarm.microprofile.openapi.api.models.info.InfoImpl in project wildfly-swarm by wildfly-swarm.
the class OpenApiParser method readInfo.
/**
* Reads an {@link Info} OpenAPI node.
* @param node
*/
private Info readInfo(JsonNode node) {
if (node == null) {
return null;
}
InfoImpl model = new InfoImpl();
model.setTitle(JsonUtil.stringProperty(node, OpenApiConstants.PROP_TITLE));
model.setDescription(JsonUtil.stringProperty(node, OpenApiConstants.PROP_DESCRIPTION));
model.setTermsOfService(JsonUtil.stringProperty(node, OpenApiConstants.PROP_TERMS_OF_SERVICE));
model.setContact(readContact(node.get(OpenApiConstants.PROP_CONTACT)));
model.setLicense(readLicense(node.get(OpenApiConstants.PROP_LICENSE)));
model.setVersion(JsonUtil.stringProperty(node, OpenApiConstants.PROP_VERSION));
readExtensions(node, model);
return model;
}
Aggregations