use of io.swagger.v3.oas.models.headers.Header in project swagger-core by swagger-api.
the class AnnotationsUtils method getHeader.
public static Optional<Header> getHeader(io.swagger.v3.oas.annotations.headers.Header header, JsonView jsonViewAnnotation) {
if (header == null) {
return Optional.empty();
}
Header headerObject = new Header();
boolean isEmpty = !StringUtils.isNotBlank(header.name());
if (StringUtils.isNotBlank(header.description())) {
headerObject.setDescription(header.description());
isEmpty = false;
}
if (StringUtils.isNotBlank(header.ref())) {
headerObject.set$ref(header.ref());
isEmpty = false;
}
if (header.deprecated()) {
headerObject.setDeprecated(header.deprecated());
}
if (header.required()) {
headerObject.setRequired(header.required());
isEmpty = false;
}
headerObject.setStyle(Header.StyleEnum.SIMPLE);
if (header.schema() != null) {
if (header.schema().implementation().equals(Void.class)) {
AnnotationsUtils.getSchemaFromAnnotation(header.schema(), jsonViewAnnotation).ifPresent(headerObject::setSchema);
}
}
if (isEmpty) {
return Optional.empty();
}
return Optional.of(headerObject);
}
use of io.swagger.v3.oas.models.headers.Header in project swagger-core by swagger-api.
the class SpecFilter method addPathItemSchemaRef.
private void addPathItemSchemaRef(PathItem pathItem, Set<String> referencedDefinitions) {
if (pathItem.getParameters() != null) {
for (Parameter parameter : pathItem.getParameters()) {
addSchemaRef(parameter.getSchema(), referencedDefinitions);
addContentSchemaRef(parameter.getContent(), referencedDefinitions);
}
}
Map<PathItem.HttpMethod, Operation> ops = pathItem.readOperationsMap();
for (Operation op : ops.values()) {
if (op.getRequestBody() != null) {
addContentSchemaRef(op.getRequestBody().getContent(), referencedDefinitions);
}
if (op.getResponses() != null) {
for (String keyResponses : op.getResponses().keySet()) {
ApiResponse response = op.getResponses().get(keyResponses);
if (response.getHeaders() != null) {
for (String keyHeaders : response.getHeaders().keySet()) {
Header header = response.getHeaders().get(keyHeaders);
addSchemaRef(header.getSchema(), referencedDefinitions);
addContentSchemaRef(header.getContent(), referencedDefinitions);
}
}
addContentSchemaRef(response.getContent(), referencedDefinitions);
}
}
if (op.getParameters() != null) {
for (Parameter parameter : op.getParameters()) {
addSchemaRef(parameter.getSchema(), referencedDefinitions);
addContentSchemaRef(parameter.getContent(), referencedDefinitions);
}
}
if (op.getCallbacks() != null) {
for (String keyCallback : op.getCallbacks().keySet()) {
Callback callback = op.getCallbacks().get(keyCallback);
for (PathItem callbackPathItem : callback.values()) {
addPathItemSchemaRef(callbackPathItem, referencedDefinitions);
}
}
}
}
}
Aggregations