From 137d56d16021cfe58facf30697ee54a1c0461e0f Mon Sep 17 00:00:00 2001 From: Maxime Morand Date: Thu, 28 Jan 2021 18:24:06 +0100 Subject: [PATCH] Add native support for short deserialization --- src/wsdl/index.ts | 2 +- .../common.xsd | 28 +++++++++++++ .../name.xsd | 25 +++++++++++ .../request.json | 3 ++ .../request.xml | 8 ++++ .../response.json | 9 ++++ .../response.xml | 14 +++++++ .../soap.wsdl | 42 +++++++++++++++++++ 8 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 test/request-response-samples/Dummy__should_deserialize_basic_types/common.xsd create mode 100644 test/request-response-samples/Dummy__should_deserialize_basic_types/name.xsd create mode 100644 test/request-response-samples/Dummy__should_deserialize_basic_types/request.json create mode 100644 test/request-response-samples/Dummy__should_deserialize_basic_types/request.xml create mode 100644 test/request-response-samples/Dummy__should_deserialize_basic_types/response.json create mode 100644 test/request-response-samples/Dummy__should_deserialize_basic_types/response.xml create mode 100644 test/request-response-samples/Dummy__should_deserialize_basic_types/soap.wsdl diff --git a/src/wsdl/index.ts b/src/wsdl/index.ts index 3ece11b29..0cc4a993f 100644 --- a/src/wsdl/index.ts +++ b/src/wsdl/index.ts @@ -436,7 +436,7 @@ export class WSDL { if (this.options && this.options.customDeserializer && this.options.customDeserializer[name]) { value = this.options.customDeserializer[name](text, top); } else { - if (name === 'int' || name === 'integer') { + if (name === 'int' || name === 'integer' || name === 'short') { value = parseInt(text, 10); } else if (name === 'double' || name === 'float' || name === 'decimal') { value = Number(text); diff --git a/test/request-response-samples/Dummy__should_deserialize_basic_types/common.xsd b/test/request-response-samples/Dummy__should_deserialize_basic_types/common.xsd new file mode 100644 index 000000000..e04c0710b --- /dev/null +++ b/test/request-response-samples/Dummy__should_deserialize_basic_types/common.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/request-response-samples/Dummy__should_deserialize_basic_types/name.xsd b/test/request-response-samples/Dummy__should_deserialize_basic_types/name.xsd new file mode 100644 index 000000000..bdc6168c2 --- /dev/null +++ b/test/request-response-samples/Dummy__should_deserialize_basic_types/name.xsd @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/request-response-samples/Dummy__should_deserialize_basic_types/request.json b/test/request-response-samples/Dummy__should_deserialize_basic_types/request.json new file mode 100644 index 000000000..62dec993f --- /dev/null +++ b/test/request-response-samples/Dummy__should_deserialize_basic_types/request.json @@ -0,0 +1,3 @@ +{ + "DummyField1": "foo & bar" +} \ No newline at end of file diff --git a/test/request-response-samples/Dummy__should_deserialize_basic_types/request.xml b/test/request-response-samples/Dummy__should_deserialize_basic_types/request.xml new file mode 100644 index 000000000..8f783b787 --- /dev/null +++ b/test/request-response-samples/Dummy__should_deserialize_basic_types/request.xml @@ -0,0 +1,8 @@ + + + + + foo & bar + + + diff --git a/test/request-response-samples/Dummy__should_deserialize_basic_types/response.json b/test/request-response-samples/Dummy__should_deserialize_basic_types/response.json new file mode 100644 index 000000000..45df4ced1 --- /dev/null +++ b/test/request-response-samples/Dummy__should_deserialize_basic_types/response.json @@ -0,0 +1,9 @@ +{ + "boolean": true, + "decimal": 1.1, + "double": 1.21, + "float": 1.321, + "int": 1, + "short": 3, + "string": "foo" +} \ No newline at end of file diff --git a/test/request-response-samples/Dummy__should_deserialize_basic_types/response.xml b/test/request-response-samples/Dummy__should_deserialize_basic_types/response.xml new file mode 100644 index 000000000..ec0ca898f --- /dev/null +++ b/test/request-response-samples/Dummy__should_deserialize_basic_types/response.xml @@ -0,0 +1,14 @@ + + + + + true + 1.1 + 1.21 + 1.321 + 1 + 3 + foo + + + diff --git a/test/request-response-samples/Dummy__should_deserialize_basic_types/soap.wsdl b/test/request-response-samples/Dummy__should_deserialize_basic_types/soap.wsdl new file mode 100644 index 000000000..814ba1bf5 --- /dev/null +++ b/test/request-response-samples/Dummy__should_deserialize_basic_types/soap.wsdl @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +