[JavaScript] add oneOf support (#13561)

* JS add oneOf support

* add validate json method

* add oneOf support to JS client

* update samples

* add todo in anyof

* switch to composed.oneOf

* update oneOf to support primitive types

* update messages

* minor fix, add more tests

* update samples

* fix npe in from model

* fix syntax error in length check

* update samples
This commit is contained in:
William Cheng
2022-10-02 13:34:50 +08:00
committed by GitHub
parent 2920c7bf91
commit 9cc23dd09d
193 changed files with 6766 additions and 4 deletions

View File

@@ -26,6 +26,7 @@
'use strict';
var api_instance;
var id = 129038120;
beforeEach(function() {
api_instance = new OpenApiPetstore.PetApi();
@@ -48,7 +49,6 @@
}
var createRandomPet = function() {
var id = new Date().getTime();
var pet = new OpenApiPetstore.Pet();
setProperty(pet, "setId", "id", id);
setProperty(pet, "setName", "name", "pet" + id);
@@ -81,6 +81,13 @@
expect(response.get('Content-Type')).to.be('application/json');
expect(fetched).to.be.a(OpenApiPetstore.Pet);
expect(JSON.stringify(fetched)).to.be('{"name":"pet129038120","photoUrls":["http://foo.bar.com/1","http://foo.bar.com/2"],"id":129038120,"category":{"name":"category129038120","id":129038120},"tags":[],"status":"available"}');
// test ApiClient.convertToType
var tag_result = OpenApiPetstore.ApiClient.convertToType(JSON.stringify(fetched), OpenApiPetstore.Pet);
expect(tag_result).to.be.a(OpenApiPetstore.Pet);
// test returned object `Pet`
expect(fetched.id).to.be(pet.id);
expect(getProperty(fetched, "getPhotoUrls", "photoUrls"))
.to.eql(getProperty(pet, "getPhotoUrls", "photoUrls"));