Search in sources :

Example 6 with ServerImpl

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 a PathItem.
 * @param config
 * @param pathName
 * @param pathItem
 */
protected static void configureServers(OpenApiConfig config, String pathName, PathItem pathItem) {
    if (pathItem == null) {
        return;
    }
    Set<String> pathServers = config.pathServers(pathName);
    if (pathServers != null && !pathServers.isEmpty()) {
        pathItem.servers(new ArrayList<>());
        for (String pathServer : pathServers) {
            Server server = new ServerImpl();
            server.setUrl(pathServer);
            pathItem.addServer(server);
        }
    }
    configureServers(config, pathItem.getGET());
    configureServers(config, pathItem.getPUT());
    configureServers(config, pathItem.getPOST());
    configureServers(config, pathItem.getDELETE());
    configureServers(config, pathItem.getHEAD());
    configureServers(config, pathItem.getOPTIONS());
    configureServers(config, pathItem.getPATCH());
    configureServers(config, pathItem.getTRACE());
}
Also used : Server(org.eclipse.microprofile.openapi.models.servers.Server) ServerImpl(org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerImpl)

Aggregations

ServerImpl (org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerImpl)6 Server (org.eclipse.microprofile.openapi.models.servers.Server)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ArrayList (java.util.ArrayList)1 PathItem (org.eclipse.microprofile.openapi.models.PathItem)1