use of org.eclipse.microprofile.openapi.models.headers.Header in project wildfly-swarm by wildfly-swarm.
the class OpenApiParser method readHeaders.
/**
* Reads the {@link Header} OpenAPI nodes.
* @param node
*/
private Map<String, Header> readHeaders(JsonNode node) {
if (node == null || !node.isObject()) {
return null;
}
Map<String, Header> models = new LinkedHashMap<>();
for (Iterator<String> fieldNames = node.fieldNames(); fieldNames.hasNext(); ) {
String fieldName = fieldNames.next();
JsonNode childNode = node.get(fieldName);
models.put(fieldName, readHeader(childNode));
}
return models;
}
use of org.eclipse.microprofile.openapi.models.headers.Header in project wildfly-swarm by wildfly-swarm.
the class OpenApiAnnotationScanner method readHeader.
/**
* Reads a Header annotation into a model.
* @param annotation
*/
private Header readHeader(AnnotationInstance annotation) {
if (annotation == null) {
return null;
}
LOG.debug("Processing a single @Header annotation.");
Header header = new HeaderImpl();
header.setDescription(JandexUtil.stringValue(annotation, OpenApiConstants.PROP_DESCRIPTION));
header.setSchema(readSchema(annotation.value(OpenApiConstants.PROP_SCHEMA)));
header.setRequired(JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_REQUIRED));
header.setDeprecated(JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_DEPRECATED));
header.setAllowEmptyValue(JandexUtil.booleanValue(annotation, OpenApiConstants.PROP_ALLOW_EMPTY_VALUE));
header.setRef(JandexUtil.refValue(annotation, RefType.Header));
return header;
}
use of org.eclipse.microprofile.openapi.models.headers.Header in project wildfly-swarm by wildfly-swarm.
the class FilterUtil method filterHeaders.
/**
* Filters the given models.
* @param filter
* @param models
*/
private static void filterHeaders(OASFilter filter, Map<String, Header> models) {
if (models == null) {
return;
}
Collection<String> keys = new ArrayList<>(models.keySet());
for (String key : keys) {
Header model = models.get(key);
filterHeader(filter, model);
if (filter.filterHeader(model) == null) {
models.remove(key);
}
}
}
use of org.eclipse.microprofile.openapi.models.headers.Header in project Payara by payara.
the class HeaderImpl method merge.
public static void merge(String headerName, Header header, Map<String, Header> headers, boolean override, ApiContext context) {
if (header == null) {
return;
}
// Get the header name
if (headerName == null || headerName.isEmpty()) {
headerName = UNKNOWN_ELEMENT_NAME;
}
// Get or create the header
Header model = headers.getOrDefault(headerName, new HeaderImpl());
headers.put(headerName, model);
// Merge the annotation
merge(header, model, override, context);
// If the merged annotation has a reference, set the name to the reference
if (model.getRef() != null) {
headers.remove(headerName);
headers.put(model.getRef().split("/")[3], model);
}
}
use of org.eclipse.microprofile.openapi.models.headers.Header in project Payara by payara.
the class HeaderImpl method createInstances.
public static Map<String, Header> createInstances(AnnotationModel annotation, ApiContext context) {
Map<String, Header> map = createMap();
List<AnnotationModel> headers = annotation.getValue("headers", List.class);
if (headers != null) {
for (AnnotationModel header : headers) {
String headerName = header.getValue("name", String.class);
if (headerName == null) {
headerName = header.getValue("ref", String.class);
}
map.put(headerName, createInstance(header, context));
}
}
return map;
}
Aggregations