[js] fix boolean in oneOf, add tests (#14380)

This commit is contained in:
William Cheng
2023-01-06 11:26:32 +08:00
committed by GitHub
parent c514dc3c1b
commit b22bf0a071
24 changed files with 646 additions and 25 deletions

View File

@@ -280,6 +280,20 @@ describe('Petstore', function() {
expect(JSON.stringify(result)).to.be(nested_one_of_json);
});
it('should serialize and deserialize StringOrBoolean correctly', function() {
// string
var json = '"Hello World"'
var result = OpenAPIPetstore.ApiClient.convertToType(JSON.parse(json), OpenAPIPetstore.StringOrBoolean);
expect(result).to.be.a(OpenAPIPetstore.StringOrBoolean);
expect(JSON.stringify(result)).to.be(json);
// boolean
json = 'true'
result = OpenAPIPetstore.ApiClient.convertToType(JSON.parse(json), OpenAPIPetstore.StringOrBoolean);
expect(result).to.be.a(OpenAPIPetstore.StringOrBoolean);
expect(JSON.stringify(result)).to.be(json);
});
});
});