-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add New Service Designer APIs #528
Conversation
fe1439c
to
b71fbf4
Compare
...sion/src/main/java/io/ballerina/servicemodelgenerator/extension/OpenApiServiceGenerator.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/ballerina/servicemodelgenerator/extension/ServiceModelGeneratorService.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/ballerina/servicemodelgenerator/extension/ServiceModelGeneratorService.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/ballerina/servicemodelgenerator/extension/ServiceModelGeneratorService.java
Outdated
Show resolved
Hide resolved
|
||
public record MetaData(String label, String description, String groupName, int groupNo) { | ||
public record MetaData(String label, String description) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public record MetaData(String label, String description) { | |
public record Metadata(String label, String description) { |
public record CommonSourceResponse(Map<String, List<TextEdit>> textEdits, String errorMsg, String stacktrace) { | ||
|
||
public CommonSourceResponse() { | ||
this(Map.of(), null, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the AbstractFlowModelResponse, can we isolate the error handling logic in the super class?
StringBuilder sb = new StringBuilder(); | ||
for (String errorMessage : errorMessages) { | ||
sb.append(DiagnosticSeverity.ERROR).append(": ").append(errorMessage).append(System.lineSeparator()); | ||
} | ||
throw new BallerinaOpenApiException(sb.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringBuilder sb = new StringBuilder(); | |
for (String errorMessage : errorMessages) { | |
sb.append(DiagnosticSeverity.ERROR).append(": ").append(errorMessage).append(System.lineSeparator()); | |
} | |
throw new BallerinaOpenApiException(sb.toString()); | |
String errorMessage = String.join(System.lineSeparator(), errorMessages); | |
throw new BallerinaOpenApiException(DiagnosticSeverity.ERROR + ": " + errorMessage); |
private String getDefaultRecordValue(RecordTypeSymbol recordTypeSymbol) { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(OPEN_BRACE); | ||
Map<String, RecordFieldSymbol> fieldDescriptors = recordTypeSymbol.fieldDescriptors(); | ||
for (Map.Entry<String, RecordFieldSymbol> fieldDescriptor : fieldDescriptors.entrySet()) { | ||
String key = fieldDescriptor.getKey(); | ||
if (key.contains("status") || key.contains("mediaType") || key.contains("headers")) { | ||
continue; | ||
} | ||
sb.append(key).append(COLON).append(SPACE) | ||
.append(getDefaultValue(fieldDescriptor.getValue().typeDescriptor())).append(COMMA) | ||
.append(SPACE); | ||
} | ||
sb.append(DEFAULT_HTTP_RESPONSE_VALUE).append(CLOSE_BRACE); | ||
return sb.toString(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this method instead of directly calling RecordUtil.getFillAllRecordFieldInsertText
Package currentPackage = project.currentPackage(); | ||
Module module = currentPackage.module(ModuleName.from(currentPackage.packageName())); | ||
ModuleId moduleId = module.moduleId(); | ||
SemanticModel semanticModel = currentPackage.getCompilation().getSemanticModel(moduleId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can get the semantic model directly from the workspace manager using this.workspacemanager.semanticModel()
String importText = String.format("%simport %s/%s;%s", System.lineSeparator(), | ||
listener.getOrgName(), listener.getModuleName(), System.lineSeparator()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String importText = String.format("%simport %s/%s;%s", System.lineSeparator(), | |
listener.getOrgName(), listener.getModuleName(), System.lineSeparator()); | |
String importText = String.format("%nimport %s/%s;%n", listener.getOrgName(), listener.getModuleName()); |
|
||
public void addValue(String value) { | ||
if (Objects.isNull(this.values)) { | ||
this.values = List.of(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list is immutable, and and you cannot call addValue afterwards.
TextEdit serviceEdit = new TextEdit(Utils.toRange(lineRange.endLine()), | ||
System.lineSeparator() + serviceDeclaration); | ||
if (!importExists(node, service.getOrgName(), service.getModuleName())) { | ||
String importText = String.format("%simport %s/%s;%s", System.lineSeparator(), service.getOrgName(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this to a util method since there is another usage?
if (document.isEmpty()) { | ||
return new CommonSourceResponse(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the API attempts to add a resource to the service but finds a missing document, this indicates a program error. The error should be sent to the front end for debugging, and an exception should be thrown.
return new CommonSourceResponse(); | ||
} | ||
NonTerminalNode parentService = functionDefinitionNode.parent(); | ||
if (!(parentService.kind().equals(SyntaxKind.SERVICE_DECLARATION))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!(parentService.kind().equals(SyntaxKind.SERVICE_DECLARATION))) { | |
if (parentService.kind() != SyntaxKind.SERVICE_DECLARATION) { |
@TharmiganK, Let's fix the comments in a separate PR. |
Purpose
Goals
Approach
User stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning