use of org.eclipse.microprofile.openapi.models.parameters.Parameter in project wildfly-swarm by wildfly-swarm.
the class OpenApiAnnotationScanner method readParameter.
/**
* Reads a Parameter annotation into a model.
* @param annotation
*/
private Parameter readParameter(AnnotationInstance annotation) {
if (annotation == null) {
return null;
}
LOG.debug("Processing a single @Link annotation.");
// Params can be hidden. Skip if that's the case.
Boolean isHidden = JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_HIDDEN);
if (isHidden != null && isHidden == Boolean.TRUE) {
return null;
}
Parameter parameter = new ParameterImpl();
parameter.setName(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_NAME));
parameter.setIn(JandexUtil.enumValue(annotation, OpenApiConstants.PROP_IN, org.eclipse.microprofile.openapi.models.parameters.Parameter.In.class));
parameter.setDescription(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_DESCRIPTION));
parameter.setRequired(JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_REQUIRED));
parameter.setDeprecated(JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_DEPRECATED));
parameter.setAllowEmptyValue(JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_ALLOW_EMPTY_VALUE));
parameter.setStyle(JandexUtil.enumValue(annotation, OpenApiConstants.PROP_STYLE, org.eclipse.microprofile.openapi.models.parameters.Parameter.Style.class));
parameter.setExplode(readExplode(JandexUtil.enumValue(annotation, OpenApiConstants.PROP_EXPLODE, org.eclipse.microprofile.openapi.annotations.enums.Explode.class)));
parameter.setAllowReserved(JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_ALLOW_RESERVED));
parameter.setSchema(readSchema(annotation.value(OpenApiConstants.PROP_SCHEMA)));
parameter.setContent(readContent(annotation.value(OpenApiConstants.PROP_CONTENT), ContentDirection.Parameter));
parameter.setExamples(readExamples(annotation.value(OpenApiConstants.PROP_EXAMPLES)));
parameter.setExample(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_EXAMPLE));
parameter.setRef(JandexUtil.refValue(annotation, RefType.Parameter));
return parameter;
}
use of org.eclipse.microprofile.openapi.models.parameters.Parameter in project wildfly-swarm by wildfly-swarm.
the class OpenApiParser method readParameterList.
/**
* Reads a {@link Parameter} OpenAPI node.
* @param node
*/
private List<Parameter> readParameterList(JsonNode node) {
if (node == null || !node.isArray()) {
return null;
}
List<Parameter> params = new ArrayList<>();
ArrayNode arrayNode = (ArrayNode) node;
for (JsonNode paramNode : arrayNode) {
params.add(readParameter(paramNode));
}
return params;
}
use of org.eclipse.microprofile.openapi.models.parameters.Parameter in project wildfly-swarm by wildfly-swarm.
the class OpenApiSerializer method writeParameterList.
/**
* Writes a list of {@link Parameter} to the JSON tree.
* @param parent
* @param models
*/
private void writeParameterList(ObjectNode parent, List<Parameter> models) {
if (models == null) {
return;
}
ArrayNode node = parent.putArray(OpenApiConstants.PROP_PARAMETERS);
for (Parameter model : models) {
ObjectNode paramNode = node.addObject();
writeParameterToNode(paramNode, model);
}
}
use of org.eclipse.microprofile.openapi.models.parameters.Parameter in project wildfly-swarm by wildfly-swarm.
the class FilterUtil method filterParameters.
/**
* Filters the given models.
* @param filter
* @param models
*/
private static void filterParameters(OASFilter filter, Map<String, Parameter> models) {
if (models == null) {
return;
}
Collection<String> keys = new ArrayList<>(models.keySet());
for (String key : keys) {
Parameter model = models.get(key);
filterParameter(filter, model);
if (filter.filterParameter(model) == null) {
models.remove(key);
}
}
}
Aggregations