use of io.swagger.models.ExternalDocs in project ballerina by ballerina-lang.
the class SwaggerResourceMapper method createExternalDocsModel.
/**
* Creates external docs swagger definitions.
* @param annotationAttributeValue The annotation attribute value for external docs.
* @param operation The swagger operation.
*/
private void createExternalDocsModel(AnnotationAttachmentAttributeValueNode annotationAttributeValue, Operation operation) {
if (null != annotationAttributeValue) {
if (annotationAttributeValue instanceof AnnotationAttachmentNode) {
AnnotationAttachmentNode externalDocAnnotationAttachment = (AnnotationAttachmentNode) annotationAttributeValue;
ExternalDocs externalDocs = new ExternalDocs();
Map<String, AnnotationAttachmentAttributeValueNode> externalDocAttributes = this.listToMap(externalDocAnnotationAttachment);
if (externalDocAttributes.containsKey("description")) {
externalDocs.setDescription(this.getStringLiteralValue(externalDocAttributes.get("description")));
}
if (externalDocAttributes.containsKey("url")) {
externalDocs.setUrl(this.getStringLiteralValue(externalDocAttributes.get("url")));
}
operation.setExternalDocs(externalDocs);
}
}
}
use of io.swagger.models.ExternalDocs in project ballerina by ballerina-lang.
the class SwaggerServiceMapper method createExternalDocModel.
/**
* Creates external docs swagger definition.
* @param annotationAttributeValue The ballerina annotation attribute value for external docs.
* @param swagger The swagger definition which the external docs needs to be build on.
*/
private void createExternalDocModel(AnnAttributeValue annotationAttributeValue, Swagger swagger) {
if (null != annotationAttributeValue) {
AnnAttachmentInfo externalDocAnnotationAttachment = annotationAttributeValue.getAnnotationAttachmentValue();
ExternalDocs externalDoc = new ExternalDocs();
for (AnnAttributeKeyValuePair annAttributeKeyValuePair : externalDocAnnotationAttachment.getAttributeKeyValuePairs()) {
if ("description".equals(annAttributeKeyValuePair.getAttributeName())) {
externalDoc.setDescription(annAttributeKeyValuePair.getAttributeValue().getStringValue());
} else if ("url".equals(annAttributeKeyValuePair.getAttributeName())) {
externalDoc.setUrl(annAttributeKeyValuePair.getAttributeValue().getStringValue());
}
}
swagger.setExternalDocs(externalDoc);
}
}
Aggregations