use of org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerImpl in project wildfly-swarm by wildfly-swarm.
the class OpenApiParser method readServer.
/**
* Reads a {@link Server} OpenAPI node.
* @param node
*/
private Server readServer(JsonNode node) {
if (node == null || !node.isObject()) {
return null;
}
ServerImpl model = new ServerImpl();
model.setUrl(JsonUtil.stringProperty(node, OpenApiConstants.PROP_URL));
model.setDescription(JsonUtil.stringProperty(node, OpenApiConstants.PROP_DESCRIPTION));
model.setVariables(readServerVariables(node.get(OpenApiConstants.PROP_VARIABLES)));
readExtensions(node, model);
return model;
}
use of org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerImpl in project wildfly-swarm by wildfly-swarm.
the class OpenApiParser method readServers.
/**
* Reads a list of {@link Server} OpenAPI nodes.
* @param node
*/
private List<Server> readServers(JsonNode node) {
if (node == null || !node.isArray()) {
return null;
}
ArrayNode nodes = (ArrayNode) node;
List<Server> rval = new ArrayList<>(nodes.size());
for (JsonNode serverNode : nodes) {
ServerImpl model = new ServerImpl();
model.setUrl(JsonUtil.stringProperty(serverNode, OpenApiConstants.PROP_URL));
model.setDescription(JsonUtil.stringProperty(serverNode, OpenApiConstants.PROP_DESCRIPTION));
model.setVariables(readServerVariables(serverNode.get(OpenApiConstants.PROP_VARIABLES)));
readExtensions(serverNode, model);
rval.add(model);
}
return rval;
}
use of org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerImpl in project wildfly-swarm by wildfly-swarm.
the class OpenApiAnnotationScanner method readServer.
/**
* Reads a single Server annotation.
* @param serverAnno
*/
private Server readServer(AnnotationInstance serverAnno) {
if (serverAnno == null) {
return null;
}
LOG.debug("Processing a single @Server annotation.");
ServerImpl server = new ServerImpl();
server.setUrl(JandexUtil.stringValue(serverAnno, OpenApiConstants.PROP_URL));
server.setDescription(JandexUtil.stringValue(serverAnno, OpenApiConstants.PROP_DESCRIPTION));
server.setVariables(readServerVariables(serverAnno.value(OpenApiConstants.PROP_VARIABLES)));
return server;
}
use of org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerImpl in project wildfly-swarm by wildfly-swarm.
the class ServersUtil method configureServers.
/**
* Configures the servers for an Operation.
* @param config
* @param operation
*/
protected static void configureServers(OpenApiConfig config, Operation operation) {
if (operation == null) {
return;
}
if (operation.getOperationId() == null) {
return;
}
Set<String> operationServers = config.operationServers(operation.getOperationId());
if (operationServers != null && !operationServers.isEmpty()) {
operation.servers(new ArrayList<>());
for (String operationServer : operationServers) {
Server server = new ServerImpl();
server.setUrl(operationServer);
operation.addServer(server);
}
}
}
use of org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerImpl in project wildfly-swarm by wildfly-swarm.
the class ServersUtil method configureServers.
public static final void configureServers(OpenApiConfig config, OpenAPI oai) {
// Start with the global servers.
Set<String> servers = config.servers();
if (servers != null && !servers.isEmpty()) {
oai.servers(new ArrayList<>());
for (String server : servers) {
Server s = new ServerImpl();
s.setUrl(server);
oai.addServer(s);
}
}
// Now the PathItem and Operation servers
Set<String> pathNames = oai.getPaths().keySet();
for (String pathName : pathNames) {
PathItem pathItem = oai.getPaths().get(pathName);
configureServers(config, pathName, pathItem);
}
}
Aggregations