Search in sources :

Example 11 with ExternalDocs

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);
        }
    }
}
Also used : AnnotationAttachmentAttributeValueNode(org.ballerinalang.model.tree.expressions.AnnotationAttachmentAttributeValueNode) ExternalDocs(io.swagger.models.ExternalDocs) AnnotationAttachmentNode(org.ballerinalang.model.tree.AnnotationAttachmentNode)

Example 12 with 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);
    }
}
Also used : AnnAttributeKeyValuePair(org.ballerinalang.util.codegen.AnnAttributeKeyValuePair) AnnAttachmentInfo(org.ballerinalang.util.codegen.AnnAttachmentInfo) ExternalDocs(io.swagger.models.ExternalDocs)

Aggregations

ExternalDocs (io.swagger.models.ExternalDocs)12 ApiKeyAuthDefinition (io.swagger.annotations.ApiKeyAuthDefinition)3 BasicAuthDefinition (io.swagger.annotations.BasicAuthDefinition)3 OAuth2Definition (io.swagger.annotations.OAuth2Definition)3 Scope (io.swagger.annotations.Scope)3 SwaggerDefinition (io.swagger.annotations.SwaggerDefinition)3 Tag (io.swagger.models.Tag)3 AnnotationAttachmentNode (org.ballerinalang.model.tree.AnnotationAttachmentNode)2 AnnotationAttachmentAttributeValueNode (org.ballerinalang.model.tree.expressions.AnnotationAttachmentAttributeValueNode)2 AnnAttachmentInfo (org.ballerinalang.util.codegen.AnnAttachmentInfo)2 Test (org.testng.annotations.Test)2 AuthorizationScope (io.swagger.annotations.AuthorizationScope)1 RefModel (io.swagger.models.RefModel)1 SecurityRequirement (io.swagger.models.SecurityRequirement)1 Swagger (io.swagger.models.Swagger)1 BasicAuthDefinition (io.swagger.models.auth.BasicAuthDefinition)1 ResourceWithExternalDocs (io.swagger.resources.ResourceWithExternalDocs)1 AnnAttributeKeyValuePair (org.ballerinalang.util.codegen.AnnAttributeKeyValuePair)1 AnnAttributeValue (org.ballerinalang.util.codegen.AnnAttributeValue)1 ParamAnnAttachmentInfo (org.ballerinalang.util.codegen.ParamAnnAttachmentInfo)1