Search in sources :

Example 1 with ServerVariablesImpl

use of org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerVariablesImpl in project wildfly-swarm by wildfly-swarm.

the class OpenApiParser method readServerVariables.

/**
 * Reads the {@link ServerVariables} OpenAPI node.
 * @param node
 */
private ServerVariables readServerVariables(JsonNode node) {
    if (node == null) {
        return null;
    }
    ServerVariablesImpl model = new ServerVariablesImpl();
    for (Iterator<String> iterator = node.fieldNames(); iterator.hasNext(); ) {
        String fieldName = iterator.next();
        if (!fieldName.toLowerCase().startsWith(OpenApiConstants.EXTENSION_PROPERTY_PREFIX)) {
            JsonNode varNode = node.get(fieldName);
            ServerVariable varModel = readServerVariable(varNode);
            model.put(fieldName, varModel);
        }
    }
    readExtensions(node, model);
    return model;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ServerVariablesImpl(org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerVariablesImpl) ServerVariable(org.eclipse.microprofile.openapi.models.servers.ServerVariable)

Example 2 with ServerVariablesImpl

use of org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerVariablesImpl in project wildfly-swarm by wildfly-swarm.

the class OpenApiAnnotationScanner method readServerVariables.

/**
 * Reads an array of ServerVariable annotations, returning a new {@link ServerVariables} model.  The
 * annotation value is an array of ServerVariable annotations.
 * @param value
 * @return
 */
private ServerVariables readServerVariables(AnnotationValue serverVariableAnnos) {
    if (serverVariableAnnos == null) {
        return null;
    }
    LOG.debug("Processing an array of @ServerVariable annotations.");
    AnnotationInstance[] nestedArray = serverVariableAnnos.asNestedArray();
    ServerVariables variables = new ServerVariablesImpl();
    for (AnnotationInstance serverVariableAnno : nestedArray) {
        String name = JandexUtil.stringValue(serverVariableAnno, OpenApiConstants.PROP_NAME);
        if (name != null) {
            variables.addServerVariable(name, readServerVariable(serverVariableAnno));
        }
    }
    return variables;
}
Also used : ServerVariables(org.eclipse.microprofile.openapi.models.servers.ServerVariables) ServerVariablesImpl(org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerVariablesImpl) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Aggregations

ServerVariablesImpl (org.wildfly.swarm.microprofile.openapi.api.models.servers.ServerVariablesImpl)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ServerVariable (org.eclipse.microprofile.openapi.models.servers.ServerVariable)1 ServerVariables (org.eclipse.microprofile.openapi.models.servers.ServerVariables)1 AnnotationInstance (org.jboss.jandex.AnnotationInstance)1