Skip to content

Commit cdb24be

Browse files
committed
Adding number type support
1 parent 23524fe commit cdb24be

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

lib/xmlSchemaFaker.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function convertSchemaToXML(name, schema, attribute, indentChar, inden) {
88
if (_.get(schema, 'xml.prefix')) {
99
tagPrefix = schema.xml.prefix ? `${schema.xml.prefix}:` : '';
1010
}
11-
if (['integer','string', 'boolean'].includes(schema.type)) {
11+
if (['integer','string', 'boolean', 'number'].includes(schema.type)) {
1212
if (schema.type === 'integer') {
1313
actualValue = '(integer)';
1414
}
@@ -18,6 +18,9 @@ function convertSchemaToXML(name, schema, attribute, indentChar, inden) {
1818
else if (schema.type === 'boolean') {
1919
actualValue = '(boolean)';
2020
}
21+
else if (schema.type === 'number') {
22+
actualValue = '(number)';
23+
}
2124
if (attribute) {
2225
return actualValue;
2326
}

test/data/valid_openapi/xmlRequestAndResponseBody.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
},
5656
"requestBoolean": {
5757
"type": "boolean"
58+
},
59+
"requestNumber": {
60+
"type": "number"
5861
}
5962
},
6063
"xml": {
@@ -79,6 +82,9 @@
7982
},
8083
"responseBoolean": {
8184
"type": "boolean"
85+
},
86+
"responseNumber": {
87+
"type": "number"
8288
}
8389
},
8490
"xml": {

test/unit/base.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,11 +1403,13 @@ describe('CONVERT FUNCTION TESTS ', function() {
14031403
' <requestInteger>(integer)</requestInteger>\n' +
14041404
' <requestString>(string)</requestString>\n' +
14051405
' <requestBoolean>(boolean)</requestBoolean>\n' +
1406+
' <requestNumber>(number)</requestNumber>\n' +
14061407
'</ex:ExampleXMLRequest>',
14071408
expectedResponseBody = '<ex:ExampleXMLResponse xmlns:ex=\"urn:ExampleXML\">\n' +
14081409
' <responseInteger>(integer)</responseInteger>\n' +
14091410
' <responseString>(string)</responseString>\n' +
14101411
' <responseBoolean>(boolean)</responseBoolean>\n' +
1412+
' <responseNumber>(number)</responseNumber>\n' +
14111413
'</ex:ExampleXMLResponse>';
14121414
expect(err).to.be.null;
14131415
expect(conversionResult.result).to.equal(true);

0 commit comments

Comments
 (0)