Skip to content
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

node-soap parsed primitive types do not match #48

Open
nahidakbar opened this issue Oct 22, 2022 · 2 comments
Open

node-soap parsed primitive types do not match #48

nahidakbar opened this issue Oct 22, 2022 · 2 comments

Comments

@nahidakbar
Copy link

The code generator is pretty nice. Probably the only well maintained one in the typescript ecosystem.

Just noticed some type mismatch between generated typescript types and what we get as request out of the node-soap library.

I don't know why and it does not have a comprehensive coverage of primitive types in any shape or form but here are the primitive types node-soap parses:

https://github.com/vpulim/node-soap/blob/master/src/wsdl/index.ts#L439

I've fixed up the issues for my personal use with the following diff:

diff --git a/src/parser.ts b/src/parser.ts
index f830cde..e1fc04b 100644
--- a/src/parser.ts
+++ b/src/parser.ts
@@ -29,6 +29,20 @@ function findReferenceDefiniton(visited: Array<VisitedDefinition>, definitionPar
     return visited.find((def) => def.parts === definitionParts);
 }
 
+const NODE_SOAP_PARSED_TYPES: { [type: string]: string } = {
+    int: "number",
+    integer: "number",
+    short: "number",
+    long: "number",
+    double: "number",
+    float: "number",
+    decimal: "number",
+    bool: "boolean",
+    boolean: "boolean",
+    dateTime: "Date",
+    date: "Date",
+};
+
 /**
  * parse definition
  * @param parsedWsdl context of parsed wsdl
@@ -95,7 +109,7 @@ function parseDefinition(
                             name: stripedPropName,
                             sourceName: propName,
                             description: type,
-                            type: "string",
+                            type: NODE_SOAP_PARSED_TYPES[type] || "string",
                             isArray: true,
                         });
                     } else if (type instanceof ComplexTypeElement) {
@@ -155,7 +169,7 @@ function parseDefinition(
                             name: propName,
                             sourceName: propName,
                             description: type,
-                            type: "string",
+                            type: NODE_SOAP_PARSED_TYPES[type] || "string",
                             isArray: false,
                         });
                     } else if (type instanceof ComplexTypeElement) {

Thought I'd let you know

@cheindl
Copy link

cheindl commented Dec 20, 2022

Looks good to me! I would appreciate if this could it make into the code base :-)

@nahidakbar
Copy link
Author

@cheindl #54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants