Search in sources :

Example 6 with AnnAttributeKeyValuePair

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

the class SwaggerServiceMapper method createContactModel.

/**
 * Creates the contact swagger definition.
 * @param annotationAttributeValue The ballerina annotation attribute value for contact.
 * @param info The info definition which the contact needs to be build on.
 */
private void createContactModel(AnnAttributeValue annotationAttributeValue, Info info) {
    if (null != annotationAttributeValue) {
        AnnAttachmentInfo contactAnnotationAttachment = annotationAttributeValue.getAnnotationAttachmentValue();
        Contact contact = new Contact();
        for (AnnAttributeKeyValuePair annAttributeKeyValuePair : contactAnnotationAttachment.getAttributeKeyValuePairs()) {
            if ("name".equals(annAttributeKeyValuePair.getAttributeName())) {
                contact.setName(annAttributeKeyValuePair.getAttributeValue().getStringValue());
            } else if ("email".equals(annAttributeKeyValuePair.getAttributeName())) {
                contact.setEmail(annAttributeKeyValuePair.getAttributeValue().getStringValue());
            } else if ("url".equals(annAttributeKeyValuePair.getAttributeName())) {
                contact.setUrl(annAttributeKeyValuePair.getAttributeValue().getStringValue());
            }
        }
        info.setContact(contact);
    }
}
Also used : AnnAttributeKeyValuePair(org.ballerinalang.util.codegen.AnnAttributeKeyValuePair) AnnAttachmentInfo(org.ballerinalang.util.codegen.AnnAttachmentInfo) Contact(io.swagger.models.Contact)

Example 7 with AnnAttributeKeyValuePair

use of org.ballerinalang.util.codegen.AnnAttributeKeyValuePair 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)7 AnnAttributeKeyValuePair (org.ballerinalang.util.codegen.AnnAttributeKeyValuePair)7 Contact (io.swagger.models.Contact)1 ExternalDocs (io.swagger.models.ExternalDocs)1 Info (io.swagger.models.Info)1 License (io.swagger.models.License)1 Tag (io.swagger.models.Tag)1 LinkedList (java.util.LinkedList)1 Developer (org.ballerinalang.swagger.code.generator.model.Developer)1 Organization (org.ballerinalang.swagger.code.generator.model.Organization)1 AnnAttributeValue (org.ballerinalang.util.codegen.AnnAttributeValue)1 ServiceInfo (org.ballerinalang.util.codegen.ServiceInfo)1