-
Notifications
You must be signed in to change notification settings - Fork 3
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
Initial implementation of WSDL to Ballerina tool #14
Initial implementation of WSDL to Ballerina tool #14
Conversation
@AzeemMuzammil why have we committed the |
@AzeemMuzammil any reason to commit dependency JARs (in the |
wsdl-cli/src/main/java/io/ballerina/wsdl/cli/ErrorMessages.java
Outdated
Show resolved
Hide resolved
wsdl-core/src/main/java/io/ballerina/wsdl/core/GeneratedSourceFile.java
Outdated
Show resolved
Hide resolved
wsdl-core/src/main/java/io/ballerina/wsdl/core/GeneratorUtils.java
Outdated
Show resolved
Hide resolved
wsdl-core/src/main/java/io/ballerina/wsdl/core/GeneratorUtils.java
Outdated
Show resolved
Hide resolved
wsdl-core/src/main/java/io/ballerina/wsdl/core/OperationProcessor.java
Outdated
Show resolved
Hide resolved
wsdl-core/src/main/java/io/ballerina/wsdl/core/OperationProcessor.java
Outdated
Show resolved
Hide resolved
List<String> processedOpOutputNames = | ||
processedOperations.stream().map(op -> op.getOperationOutput().getName()).toList(); | ||
if (processedOpOutputNames.contains(wsdlOperation.getOperationOutput().getName())) { | ||
return new ArrayList<>(); |
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.
return new ArrayList<>(); | |
return Collections.emptyList(); |
wsdl-core/src/main/java/io/ballerina/wsdl/core/OperationProcessor.java
Outdated
Show resolved
Hide resolved
for (WSDLPart outputPart : outputParts) { | ||
List<Field> outputFields = partProcessor.generateFields(outputPart); | ||
fields.addAll(outputFields); | ||
} |
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.
Shall we check whether we can do this ?
for (WSDLPart outputPart : outputParts) { | |
List<Field> outputFields = partProcessor.generateFields(outputPart); | |
fields.addAll(outputFields); | |
} | |
outputParts.map(part -> partProcessor.generateFields(outputPart)).forEach(outputFields -> fields.addAll(outputFields)); |
wsdl-core/src/main/java/io/ballerina/wsdl/core/SchemaManager.java
Outdated
Show resolved
Hide resolved
wsdl-core/src/main/java/io/ballerina/wsdl/core/SchemaManager.java
Outdated
Show resolved
Hide resolved
public void initializeSchemas(Map<String, XmlSchema> targetNSToSchema) { | ||
this.targetNSToSchema = targetNSToSchema; | ||
} |
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 don't need this function to initialize the SchemeManager
right ? We can do this within the constructor itself.
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.
This is a singleton, Constructor is private
private WSDLService getSOAPService(Definition wsdlDefinition) { | ||
@SuppressWarnings("unchecked") | ||
Collection<Service> services = wsdlDefinition.getAllServices().values(); | ||
for (Service service : services) { | ||
@SuppressWarnings("unchecked") | ||
Collection<Port> ports = service.getPorts().values(); |
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.
private WSDLService getSOAPService(Definition wsdlDefinition) { | |
@SuppressWarnings("unchecked") | |
Collection<Service> services = wsdlDefinition.getAllServices().values(); | |
for (Service service : services) { | |
@SuppressWarnings("unchecked") | |
Collection<Port> ports = service.getPorts().values(); | |
@SuppressWarnings("unchecked") | |
private WSDLService getSOAPService(Definition wsdlDefinition) { | |
Collection<Service> services = wsdlDefinition.getAllServices().values(); | |
for (Service service : services) { | |
Collection<Port> ports = service.getPorts().values(); |
for (Port port : ports) { | ||
List<?> extensions = port.getExtensibilityElements(); | ||
for (Object extension : extensions) { | ||
if (extension instanceof SOAPAddress || extension instanceof SOAP12Address) { |
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.
I would rather decouple this condition into if and if-else block. That would simplify the mental mapping and improve the readability. And it would allow us to use Java instanceOf pattern-matching [1] and remove the redundant casting.
[1] - https://www.baeldung.com/java-pattern-matching-instanceof
} | ||
} | ||
} | ||
return 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.
Any reason to return null here ? IMO null should be avoided and use Optionals instead. I think this answer [1] cover the why we should use optionals in a high-level
wsdl-core/src/main/java/io/ballerina/wsdl/core/XMLSchemaParser.java
Outdated
Show resolved
Hide resolved
wsdl-core/src/main/java/io/ballerina/wsdl/core/XMLSchemaParser.java
Outdated
Show resolved
Hide resolved
wsdl-core/src/main/java/io/ballerina/wsdl/core/OperationProcessor.java
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,68 @@ | |||
///* | |||
// * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. |
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.
Licence should be updated
wsdl-core/src/main/java/io/ballerina/wsdl/core/GeneratorUtils.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
public void printLongDesc(StringBuilder out) { | ||
|
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.
Append your help text here to the out
string builder. The CLI will print it from bal help wsdl
|
||
@Override | ||
public void execute() { | ||
if (inputPath == null || inputPath.isBlank()) { |
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.
Let's add a new --help flag. For this flag and for no options/ args, we can print the help command.
@CommandLine.Option(names = {"-i", "--input"}, description = "Relative path to the WSDL file") | ||
private String inputPath; | ||
|
||
@CommandLine.Option(names = {"--operations"}, description = "Comma-separated operation names to generate") |
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.
See if we can take operations into an array using the Picocli utilities itself.
* @since 0.1.0 | ||
*/ | ||
public class Messages { | ||
public static final String MISSING_WSDL_PATH = "Error: Missing input WSDL file path. " + |
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.
Let's use a property file here
@@ -0,0 +1,20 @@ | |||
// Copyright (c) 2024 WSO2 Inc. (http://www.wso2.org). |
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 don't need any Ballerina code inside our package. We can have empty projects when we do a bal pack
for tools. So let's remove this
@@ -0,0 +1 @@ | |||
Ballerina WSDL Tools |
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.
Let's have a proper Module.md that explains what this tool does. Although currently we don't display tool information in the Ballerina central, soon we will. The tool Module.md will be used to show the tool information (similar to what we do with packages)
|
||
[ballerina] | ||
dependencies-toml-version = "2" | ||
distribution-version = "2201.9.1" |
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.
Let's use 2201.9.2 since it is published now
//publishToMavenLocal.dependsOn build | ||
//publish.dependsOn build |
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 we don't need this dependency, can remove
* | ||
* @since 0.1.0 | ||
*/ | ||
public class XsdToRecordGenerator { |
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.
Are we generating the closed record with this?
Purpose
Goals
Approach
User stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning