Search in sources :

Example 1 with Developer

use of org.ballerinalang.swagger.code.generator.model.Developer 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);
    }
}
Also used : AnnAttributeKeyValuePair(org.ballerinalang.util.codegen.AnnAttributeKeyValuePair) AnnAttachmentInfo(org.ballerinalang.util.codegen.AnnAttachmentInfo) Developer(org.ballerinalang.swagger.code.generator.model.Developer)

Aggregations

Developer (org.ballerinalang.swagger.code.generator.model.Developer)1 AnnAttachmentInfo (org.ballerinalang.util.codegen.AnnAttachmentInfo)1 AnnAttributeKeyValuePair (org.ballerinalang.util.codegen.AnnAttributeKeyValuePair)1