Search in sources :

Example 31 with AnnAttachmentInfo

use of org.ballerinalang.util.codegen.AnnAttachmentInfo in project ballerina by ballerina-lang.

the class SwaggerServiceMapper method createTagModel.

/**
 * Creates tag swagger definition.
 * @param annotationAttributeValue The ballerina annotation attribute value for tag.
 * @param swagger The swagger definition which the tags needs to be build on.
 */
private void createTagModel(AnnAttributeValue annotationAttributeValue, Swagger swagger) {
    if (null != annotationAttributeValue && annotationAttributeValue.getAttributeValueArray().length > 0) {
        List<Tag> tags = new LinkedList<>();
        for (AnnAttributeValue tagAttributeValue : annotationAttributeValue.getAttributeValueArray()) {
            AnnAttachmentInfo tagAnnotationAttachment = tagAttributeValue.getAnnotationAttachmentValue();
            Tag tag = new Tag();
            for (AnnAttributeKeyValuePair annAttributeKeyValuePair : tagAnnotationAttachment.getAttributeKeyValuePairs()) {
                if ("name".equals(annAttributeKeyValuePair.getAttributeName())) {
                    tag.setName(annAttributeKeyValuePair.getAttributeValue().getStringValue());
                } else if ("description".equals(annAttributeKeyValuePair.getAttributeName())) {
                    tag.setDescription(annAttributeKeyValuePair.getAttributeValue().getStringValue());
                }
            }
            tags.add(tag);
        }
        swagger.setTags(tags);
    }
}
Also used : AnnAttributeKeyValuePair(org.ballerinalang.util.codegen.AnnAttributeKeyValuePair) AnnAttachmentInfo(org.ballerinalang.util.codegen.AnnAttachmentInfo) Tag(io.swagger.models.Tag) AnnAttributeValue(org.ballerinalang.util.codegen.AnnAttributeValue) LinkedList(java.util.LinkedList)

Aggregations

AnnAttachmentInfo (org.ballerinalang.util.codegen.AnnAttachmentInfo)31 AnnAttributeValue (org.ballerinalang.util.codegen.AnnAttributeValue)17 ParamAnnAttachmentInfo (org.ballerinalang.util.codegen.ParamAnnAttachmentInfo)10 AnnotationAttributeInfo (org.ballerinalang.util.codegen.attributes.AnnotationAttributeInfo)10 Test (org.testng.annotations.Test)10 AnnAttributeKeyValuePair (org.ballerinalang.util.codegen.AnnAttributeKeyValuePair)7 HashMap (java.util.HashMap)5 LinkedList (java.util.LinkedList)3 ExternalDocs (io.swagger.models.ExternalDocs)2 Scheme (io.swagger.models.Scheme)2 BodyParameter (io.swagger.models.parameters.BodyParameter)2 PathParameter (io.swagger.models.parameters.PathParameter)2 QueryParameter (io.swagger.models.parameters.QueryParameter)2 Contact (io.swagger.models.Contact)1 Info (io.swagger.models.Info)1 License (io.swagger.models.License)1 Model (io.swagger.models.Model)1 ModelImpl (io.swagger.models.ModelImpl)1 RefModel (io.swagger.models.RefModel)1 Response (io.swagger.models.Response)1