use of org.ballerinalang.util.codegen.AnnAttributeKeyValuePair in project ballerina by ballerina-lang.
the class SwaggerServiceMapper method createDevelopersModel.
/**
* Creates vendor extension for developers.
* @param annotationAttributeValue The annotation attribute value for developer vendor extension.
* @param info The info definition.
*/
private void createDevelopersModel(AnnAttributeValue annotationAttributeValue, Info info) {
if (null != annotationAttributeValue && annotationAttributeValue.getAttributeValueArray().length > 0) {
Developer[] developers = new Developer[annotationAttributeValue.getAttributeValueArray().length];
for (int i = 0; i < annotationAttributeValue.getAttributeValueArray().length; i++) {
AnnAttachmentInfo developerAnnotation = annotationAttributeValue.getAttributeValueArray()[i].getAnnotationAttachmentValue();
Developer developer = new Developer();
for (AnnAttributeKeyValuePair annAttributeKeyValuePair : developerAnnotation.getAttributeKeyValuePairs()) {
if ("name".equals(annAttributeKeyValuePair.getAttributeName())) {
developer.setName(annAttributeKeyValuePair.getAttributeValue().getStringValue());
} else if ("email".equals(annAttributeKeyValuePair.getAttributeName())) {
developer.setEmail(annAttributeKeyValuePair.getAttributeValue().getStringValue());
}
}
developers[i] = developer;
}
info.setVendorExtension("x-developers", developers);
}
}
use of org.ballerinalang.util.codegen.AnnAttributeKeyValuePair in project ballerina by ballerina-lang.
the class SwaggerServiceMapper method parseServiceInfoAnnotationAttachment.
/**
* Parses the 'ServiceInfo' annotation and build the swagger definition for it.
* @param service The ballerina service which has the 'ServiceInfo' annotation attachment.
* @param swagger The swagger definition to be built up.
*/
private void parseServiceInfoAnnotationAttachment(ServiceInfo service, Swagger swagger) {
AnnAttachmentInfo swaggerInfoAnnotation = service.getAnnotationAttachmentInfo(SwaggerConstants.SWAGGER_PACKAGE_PATH, "ServiceInfo");
Info info = new Info().version("1.0.0").title(service.getName());
if (null != swaggerInfoAnnotation) {
for (AnnAttributeKeyValuePair annAttributeKeyValuePair : swaggerInfoAnnotation.getAttributeKeyValuePairs()) {
if ("version".equals(annAttributeKeyValuePair.getAttributeName())) {
info.version(annAttributeKeyValuePair.getAttributeValue().getStringValue());
} else if ("title".equals(annAttributeKeyValuePair.getAttributeName())) {
info.title(annAttributeKeyValuePair.getAttributeValue().getStringValue());
} else if ("description".equals(annAttributeKeyValuePair.getAttributeName())) {
info.description(annAttributeKeyValuePair.getAttributeValue().getStringValue());
} else if ("termsOfService".equals(annAttributeKeyValuePair.getAttributeName())) {
info.termsOfService(annAttributeKeyValuePair.getAttributeValue().getStringValue());
} else if ("contact".equals(annAttributeKeyValuePair.getAttributeName())) {
this.createContactModel(annAttributeKeyValuePair.getAttributeValue(), info);
} else if ("license".equals(annAttributeKeyValuePair.getAttributeName())) {
this.createLicenseModel(annAttributeKeyValuePair.getAttributeValue(), info);
} else if ("externalDoc".equals(annAttributeKeyValuePair.getAttributeName())) {
this.createExternalDocModel(annAttributeKeyValuePair.getAttributeValue(), swagger);
} else if ("tags".equals(annAttributeKeyValuePair.getAttributeName())) {
this.createTagModel(annAttributeKeyValuePair.getAttributeValue(), swagger);
} else if ("organization".equals(annAttributeKeyValuePair.getAttributeName())) {
this.createOrganizationModel(annAttributeKeyValuePair.getAttributeValue(), info);
} else if ("developers".equals(annAttributeKeyValuePair.getAttributeName())) {
this.createDevelopersModel(annAttributeKeyValuePair.getAttributeValue(), info);
}
}
}
swagger.setInfo(info);
}
use of org.ballerinalang.util.codegen.AnnAttributeKeyValuePair in project ballerina by ballerina-lang.
the class SwaggerServiceMapper method createOrganizationModel.
/**
* Creates vendor extension for organization.
* @param annotationAttributeValue The annotation attribute value for organization vendor extension.
* @param info The info definition.
*/
private void createOrganizationModel(AnnAttributeValue annotationAttributeValue, Info info) {
if (null != annotationAttributeValue) {
AnnAttachmentInfo organizationAnnotationAttachment = annotationAttributeValue.getAnnotationAttachmentValue();
Organization organization = new Organization();
for (AnnAttributeKeyValuePair annAttributeKeyValuePair : organizationAnnotationAttachment.getAttributeKeyValuePairs()) {
if ("name".equals(annAttributeKeyValuePair.getAttributeName())) {
organization.setName(annAttributeKeyValuePair.getAttributeValue().getStringValue());
} else if ("url".equals(annAttributeKeyValuePair.getAttributeName())) {
organization.setUrl(annAttributeKeyValuePair.getAttributeValue().getStringValue());
}
}
info.setVendorExtension("x-organization", organization);
}
}
use of org.ballerinalang.util.codegen.AnnAttributeKeyValuePair 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);
}
}
use of org.ballerinalang.util.codegen.AnnAttributeKeyValuePair in project ballerina by ballerina-lang.
the class SwaggerServiceMapper method createLicenseModel.
/**
* Creates the license swagger definition.
* @param annotationAttributeValue The ballerina annotation attribute value for license.
* @param info The info definition which the license needs to be build on.
*/
private void createLicenseModel(AnnAttributeValue annotationAttributeValue, Info info) {
if (null != annotationAttributeValue) {
AnnAttachmentInfo licenseAnnotationAttachment = annotationAttributeValue.getAnnotationAttachmentValue();
License license = new License();
for (AnnAttributeKeyValuePair annAttributeKeyValuePair : licenseAnnotationAttachment.getAttributeKeyValuePairs()) {
if ("name".equals(annAttributeKeyValuePair.getAttributeName())) {
license.setName(annAttributeKeyValuePair.getAttributeValue().getStringValue());
} else if ("url".equals(annAttributeKeyValuePair.getAttributeName())) {
license.setUrl(annAttributeKeyValuePair.getAttributeValue().getStringValue());
}
}
info.setLicense(license);
}
}
Aggregations