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);
}
}
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);
}
}
Aggregations