for (FunctionNode function : serviceNode.getResources()) { final BLangFunction resourceNode = (BLangFunction) function; if (resourceNode.symbol.params.stream().filter(varSym -> varSym.type.tsymbol != null)
public HttpServiceTemplate(BLangPackage builtTestFile, BLangService service, BLangTypeInit init, BiConsumer<Integer, Integer> focusLineAcceptor) { super(builtTestFile, focusLineAcceptor); String serviceName = service.name.value; String serviceUriTemp = HTTP + DEFAULT_IP + ":" + DEFAULT_PORT; boolean isSecureTemp = isSecureService(init); String protocol = ((isSecureTemp) ? HTTPS : HTTP); Optional<String> optionalPort = findServicePort(init); serviceUriTemp = optionalPort.map(port -> protocol + DEFAULT_IP + ":" + port).orElse(serviceUriTemp); this.isSecure = isSecureTemp; this.serviceUri = serviceUriTemp; // Retrieve Service base path String tempServiceBasePath = "/" + serviceName; // If service base path overridden by annotations for (BLangAnnotationAttachment annotation : service.annAttachments) { if (annotation.expr instanceof BLangRecordLiteral) { BLangRecordLiteral record = (BLangRecordLiteral) annotation.expr; Optional<String> basePath = searchStringField(HttpConstants.ANN_CONFIG_ATTR_BASE_PATH, record); tempServiceBasePath = basePath.orElse(tempServiceBasePath); } } this.serviceUriStrName = getSafeName(lowerCaseFirstLetter(serviceName) + "Uri"); this.testServiceFunctionName = getSafeName("test" + upperCaseFirstLetter(serviceName)); this.serviceBasePath = tempServiceBasePath; this.resources = service.getResources(); }
final BLangService serviceNode = (BLangService) service; List<BLangFunction> resources = serviceNode.getResources(); boolean validReturnType = true; for (BLangFunction resourceNode : resources) {
/** * This method will convert ballerina @Service to swaggers @Swagger object. * * @param service ballerina @Service object to be map to swagger definition * @param swagger Swagger model to populate * @return Swagger object which represent current service. */ public Swagger convertServiceToSwagger(BLangService service, Swagger swagger) { // Setting default values. swagger.setBasePath('/' + service.getName().getValue()); this.parseServiceInfoAnnotationAttachment(service, swagger); this.parseConfigAnnotationAttachment(service, swagger); SwaggerResourceMapper resourceMapper = new SwaggerResourceMapper(swagger, this.httpAlias, this.swaggerAlias); swagger.setPaths(resourceMapper.convertResourceToPath(service.getResources())); return swagger; }