forked from loafle/openapi-generator-original
[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:
@@ -19,12 +19,15 @@ import ApiResponse from './model/ApiResponse';
|
||||
import ArrayOfArrayOfNumberOnly from './model/ArrayOfArrayOfNumberOnly';
|
||||
import ArrayOfNumberOnly from './model/ArrayOfNumberOnly';
|
||||
import ArrayTest from './model/ArrayTest';
|
||||
import BasquePig from './model/BasquePig';
|
||||
import Capitalization from './model/Capitalization';
|
||||
import Cat from './model/Cat';
|
||||
import CatAllOf from './model/CatAllOf';
|
||||
import Category from './model/Category';
|
||||
import ClassModel from './model/ClassModel';
|
||||
import Client from './model/Client';
|
||||
import Color from './model/Color';
|
||||
import DanishPig from './model/DanishPig';
|
||||
import DeprecatedObject from './model/DeprecatedObject';
|
||||
import Dog from './model/Dog';
|
||||
import DogAllOf from './model/DogAllOf';
|
||||
@@ -43,6 +46,8 @@ import MapTest from './model/MapTest';
|
||||
import MixedPropertiesAndAdditionalPropertiesClass from './model/MixedPropertiesAndAdditionalPropertiesClass';
|
||||
import Model200Response from './model/Model200Response';
|
||||
import Name from './model/Name';
|
||||
import NestedColor from './model/NestedColor';
|
||||
import NestedOneOf from './model/NestedOneOf';
|
||||
import NullableClass from './model/NullableClass';
|
||||
import NumberOnly from './model/NumberOnly';
|
||||
import ObjectWithDeprecatedFields from './model/ObjectWithDeprecatedFields';
|
||||
@@ -54,6 +59,7 @@ import OuterEnumInteger from './model/OuterEnumInteger';
|
||||
import OuterEnumIntegerDefaultValue from './model/OuterEnumIntegerDefaultValue';
|
||||
import OuterObjectWithEnumProperty from './model/OuterObjectWithEnumProperty';
|
||||
import Pet from './model/Pet';
|
||||
import Pig from './model/Pig';
|
||||
import ReadOnlyFirst from './model/ReadOnlyFirst';
|
||||
import Return from './model/Return';
|
||||
import SpecialModelName from './model/SpecialModelName';
|
||||
@@ -142,6 +148,12 @@ export {
|
||||
*/
|
||||
ArrayTest,
|
||||
|
||||
/**
|
||||
* The BasquePig model constructor.
|
||||
* @property {module:model/BasquePig}
|
||||
*/
|
||||
BasquePig,
|
||||
|
||||
/**
|
||||
* The Capitalization model constructor.
|
||||
* @property {module:model/Capitalization}
|
||||
@@ -178,6 +190,18 @@ export {
|
||||
*/
|
||||
Client,
|
||||
|
||||
/**
|
||||
* The Color model constructor.
|
||||
* @property {module:model/Color}
|
||||
*/
|
||||
Color,
|
||||
|
||||
/**
|
||||
* The DanishPig model constructor.
|
||||
* @property {module:model/DanishPig}
|
||||
*/
|
||||
DanishPig,
|
||||
|
||||
/**
|
||||
* The DeprecatedObject model constructor.
|
||||
* @property {module:model/DeprecatedObject}
|
||||
@@ -286,6 +310,18 @@ export {
|
||||
*/
|
||||
Name,
|
||||
|
||||
/**
|
||||
* The NestedColor model constructor.
|
||||
* @property {module:model/NestedColor}
|
||||
*/
|
||||
NestedColor,
|
||||
|
||||
/**
|
||||
* The NestedOneOf model constructor.
|
||||
* @property {module:model/NestedOneOf}
|
||||
*/
|
||||
NestedOneOf,
|
||||
|
||||
/**
|
||||
* The NullableClass model constructor.
|
||||
* @property {module:model/NullableClass}
|
||||
@@ -352,6 +388,12 @@ export {
|
||||
*/
|
||||
Pet,
|
||||
|
||||
/**
|
||||
* The Pig model constructor.
|
||||
* @property {module:model/Pig}
|
||||
*/
|
||||
Pig,
|
||||
|
||||
/**
|
||||
* The ReadOnlyFirst model constructor.
|
||||
* @property {module:model/ReadOnlyFirst}
|
||||
|
||||
@@ -57,9 +57,21 @@ class AdditionalPropertiesClass {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>AdditionalPropertiesClass</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>AdditionalPropertiesClass</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Object.<String, String>} map_property
|
||||
*/
|
||||
|
||||
@@ -59,9 +59,35 @@ class Animal {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Animal</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Animal</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// check to make sure all required properties are present in the JSON string
|
||||
for (const property of Animal.RequiredProperties) {
|
||||
if (!data[property]) {
|
||||
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['className'] && !(typeof data['className'] === 'string' || data['className'] instanceof String)) {
|
||||
throw new Error("Expected the field `className` to be a primitive type in the JSON string but got " + data['className']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['color'] && !(typeof data['color'] === 'string' || data['color'] instanceof String)) {
|
||||
throw new Error("Expected the field `color` to be a primitive type in the JSON string but got " + data['color']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Animal.RequiredProperties = ["className"];
|
||||
|
||||
/**
|
||||
* @member {String} className
|
||||
*/
|
||||
|
||||
@@ -60,9 +60,29 @@ class ApiResponse {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>ApiResponse</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>ApiResponse</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['type'] && !(typeof data['type'] === 'string' || data['type'] instanceof String)) {
|
||||
throw new Error("Expected the field `type` to be a primitive type in the JSON string but got " + data['type']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['message'] && !(typeof data['message'] === 'string' || data['message'] instanceof String)) {
|
||||
throw new Error("Expected the field `message` to be a primitive type in the JSON string but got " + data['message']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Number} code
|
||||
*/
|
||||
|
||||
@@ -54,9 +54,25 @@ class ArrayOfArrayOfNumberOnly {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>ArrayOfArrayOfNumberOnly</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>ArrayOfArrayOfNumberOnly</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['ArrayArrayNumber'])) {
|
||||
throw new Error("Expected the field `ArrayArrayNumber` to be an array in the JSON data but got " + data['ArrayArrayNumber']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Array.<Array.<Number>>} ArrayArrayNumber
|
||||
*/
|
||||
|
||||
@@ -54,9 +54,25 @@ class ArrayOfNumberOnly {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>ArrayOfNumberOnly</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>ArrayOfNumberOnly</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['ArrayNumber'])) {
|
||||
throw new Error("Expected the field `ArrayNumber` to be an array in the JSON data but got " + data['ArrayNumber']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Array.<Number>} ArrayNumber
|
||||
*/
|
||||
|
||||
@@ -61,9 +61,33 @@ class ArrayTest {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>ArrayTest</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>ArrayTest</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['array_of_string'])) {
|
||||
throw new Error("Expected the field `array_of_string` to be an array in the JSON data but got " + data['array_of_string']);
|
||||
}
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['array_array_of_integer'])) {
|
||||
throw new Error("Expected the field `array_array_of_integer` to be an array in the JSON data but got " + data['array_array_of_integer']);
|
||||
}
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['array_array_of_model'])) {
|
||||
throw new Error("Expected the field `array_array_of_model` to be an array in the JSON data but got " + data['array_array_of_model']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Array.<String>} array_of_string
|
||||
*/
|
||||
|
||||
109
samples/client/petstore/javascript-es6/src/model/BasquePig.js
Normal file
109
samples/client/petstore/javascript-es6/src/model/BasquePig.js
Normal file
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
import ApiClient from '../ApiClient';
|
||||
|
||||
/**
|
||||
* The BasquePig model module.
|
||||
* @module model/BasquePig
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class BasquePig {
|
||||
/**
|
||||
* Constructs a new <code>BasquePig</code>.
|
||||
* @alias module:model/BasquePig
|
||||
* @param className {String}
|
||||
* @param color {String}
|
||||
*/
|
||||
constructor(className, color) {
|
||||
|
||||
BasquePig.initialize(this, className, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the fields of this object.
|
||||
* This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
|
||||
* Only for internal use.
|
||||
*/
|
||||
static initialize(obj, className, color) {
|
||||
obj['className'] = className;
|
||||
obj['color'] = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>BasquePig</code> from a plain JavaScript object, optionally creating a new instance.
|
||||
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @param {module:model/BasquePig} obj Optional instance to populate.
|
||||
* @return {module:model/BasquePig} The populated <code>BasquePig</code> instance.
|
||||
*/
|
||||
static constructFromObject(data, obj) {
|
||||
if (data) {
|
||||
obj = obj || new BasquePig();
|
||||
|
||||
if (data.hasOwnProperty('className')) {
|
||||
obj['className'] = ApiClient.convertToType(data['className'], 'String');
|
||||
}
|
||||
if (data.hasOwnProperty('color')) {
|
||||
obj['color'] = ApiClient.convertToType(data['color'], 'String');
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>BasquePig</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>BasquePig</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// check to make sure all required properties are present in the JSON string
|
||||
for (const property of BasquePig.RequiredProperties) {
|
||||
if (!data[property]) {
|
||||
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['className'] && !(typeof data['className'] === 'string' || data['className'] instanceof String)) {
|
||||
throw new Error("Expected the field `className` to be a primitive type in the JSON string but got " + data['className']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['color'] && !(typeof data['color'] === 'string' || data['color'] instanceof String)) {
|
||||
throw new Error("Expected the field `color` to be a primitive type in the JSON string but got " + data['color']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
BasquePig.RequiredProperties = ["className", "color"];
|
||||
|
||||
/**
|
||||
* @member {String} className
|
||||
*/
|
||||
BasquePig.prototype['className'] = undefined;
|
||||
|
||||
/**
|
||||
* @member {String} color
|
||||
*/
|
||||
BasquePig.prototype['color'] = undefined;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export default BasquePig;
|
||||
|
||||
@@ -69,9 +69,45 @@ class Capitalization {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Capitalization</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Capitalization</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['smallCamel'] && !(typeof data['smallCamel'] === 'string' || data['smallCamel'] instanceof String)) {
|
||||
throw new Error("Expected the field `smallCamel` to be a primitive type in the JSON string but got " + data['smallCamel']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['CapitalCamel'] && !(typeof data['CapitalCamel'] === 'string' || data['CapitalCamel'] instanceof String)) {
|
||||
throw new Error("Expected the field `CapitalCamel` to be a primitive type in the JSON string but got " + data['CapitalCamel']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['small_Snake'] && !(typeof data['small_Snake'] === 'string' || data['small_Snake'] instanceof String)) {
|
||||
throw new Error("Expected the field `small_Snake` to be a primitive type in the JSON string but got " + data['small_Snake']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['Capital_Snake'] && !(typeof data['Capital_Snake'] === 'string' || data['Capital_Snake'] instanceof String)) {
|
||||
throw new Error("Expected the field `Capital_Snake` to be a primitive type in the JSON string but got " + data['Capital_Snake']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['SCA_ETH_Flow_Points'] && !(typeof data['SCA_ETH_Flow_Points'] === 'string' || data['SCA_ETH_Flow_Points'] instanceof String)) {
|
||||
throw new Error("Expected the field `SCA_ETH_Flow_Points` to be a primitive type in the JSON string but got " + data['SCA_ETH_Flow_Points']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['ATT_NAME'] && !(typeof data['ATT_NAME'] === 'string' || data['ATT_NAME'] instanceof String)) {
|
||||
throw new Error("Expected the field `ATT_NAME` to be a primitive type in the JSON string but got " + data['ATT_NAME']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} smallCamel
|
||||
*/
|
||||
|
||||
@@ -63,9 +63,27 @@ class Cat {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Cat</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Cat</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// check to make sure all required properties are present in the JSON string
|
||||
for (const property of Cat.RequiredProperties) {
|
||||
if (!data[property]) {
|
||||
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Cat.RequiredProperties = ["className"];
|
||||
|
||||
/**
|
||||
* @member {Boolean} declawed
|
||||
*/
|
||||
|
||||
@@ -54,9 +54,21 @@ class CatAllOf {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>CatAllOf</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>CatAllOf</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Boolean} declawed
|
||||
*/
|
||||
|
||||
@@ -59,9 +59,31 @@ class Category {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Category</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Category</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// check to make sure all required properties are present in the JSON string
|
||||
for (const property of Category.RequiredProperties) {
|
||||
if (!data[property]) {
|
||||
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['name'] && !(typeof data['name'] === 'string' || data['name'] instanceof String)) {
|
||||
throw new Error("Expected the field `name` to be a primitive type in the JSON string but got " + data['name']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Category.RequiredProperties = ["name"];
|
||||
|
||||
/**
|
||||
* @member {Number} id
|
||||
*/
|
||||
|
||||
@@ -55,9 +55,25 @@ class ClassModel {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>ClassModel</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>ClassModel</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['_class'] && !(typeof data['_class'] === 'string' || data['_class'] instanceof String)) {
|
||||
throw new Error("Expected the field `_class` to be a primitive type in the JSON string but got " + data['_class']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} _class
|
||||
*/
|
||||
|
||||
@@ -54,9 +54,25 @@ class Client {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Client</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Client</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['client'] && !(typeof data['client'] === 'string' || data['client'] instanceof String)) {
|
||||
throw new Error("Expected the field `client` to be a primitive type in the JSON string but got " + data['client']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} client
|
||||
*/
|
||||
|
||||
154
samples/client/petstore/javascript-es6/src/model/Color.js
Normal file
154
samples/client/petstore/javascript-es6/src/model/Color.js
Normal file
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
import ApiClient from '../ApiClient';
|
||||
|
||||
/**
|
||||
* The Color model module.
|
||||
* @module model/Color
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class Color {
|
||||
/**
|
||||
* Constructs a new <code>Color</code>.
|
||||
* RGB array, RGBA array, or hex string.
|
||||
* @alias module:model/Color
|
||||
* @param {(module:model/String|module:model/[Number])} The actual instance to initialize Color.
|
||||
*/
|
||||
constructor(obj = null) {
|
||||
this.actualInstance = obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>Color</code> from a plain JavaScript object, optionally creating a new instance.
|
||||
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @param {module:model/Color} obj Optional instance to populate.
|
||||
* @return {module:model/Color} The populated <code>Color</code> instance.
|
||||
*/
|
||||
static constructFromObject(data, obj) {
|
||||
if (!data) {
|
||||
return new Color();
|
||||
}
|
||||
var match = 0;
|
||||
var errorMessages = [];
|
||||
// RGB three element array with values 0-255.
|
||||
try {
|
||||
// validate array data type
|
||||
if (!Array.isArray(data)) {
|
||||
throw new Error("Invalid data type. Expecting array. Data: " + data);
|
||||
}
|
||||
if (data.length > 3 || data.length < 3) {
|
||||
throw new Error("Invalid array size. Minimim: 3. Maximum: 3. Data: " + data);
|
||||
}
|
||||
// validate array of integer
|
||||
for (const item of data) {
|
||||
if (!(typeof item === 'number' && item % 1 === 0)) {
|
||||
throw new Error("Invalid array items. Must be integer. Data: " + data);
|
||||
}
|
||||
if (item > 255 || item < 0) {
|
||||
throw new Error("Invalid integer value in an array items. Max.: 255. Min.: 0. Data: " + data);
|
||||
}
|
||||
}
|
||||
obj = new Color(data);
|
||||
match++;
|
||||
} catch(err) {
|
||||
// json data failed to deserialize into [Number]
|
||||
errorMessages.push("Failed to construct [Number]: " + err)
|
||||
}
|
||||
|
||||
// RGBA four element array with values 0-255.
|
||||
try {
|
||||
// validate array data type
|
||||
if (!Array.isArray(data)) {
|
||||
throw new Error("Invalid data type. Expecting array. Data: " + data);
|
||||
}
|
||||
if (data.length > 4 || data.length < 4) {
|
||||
throw new Error("Invalid array size. Minimim: 4. Maximum: 4. Data: " + data);
|
||||
}
|
||||
// validate array of integer
|
||||
for (const item of data) {
|
||||
if (!(typeof item === 'number' && item % 1 === 0)) {
|
||||
throw new Error("Invalid array items. Must be integer. Data: " + data);
|
||||
}
|
||||
if (item > 255 || item < 0) {
|
||||
throw new Error("Invalid integer value in an array items. Max.: 255. Min.: 0. Data: " + data);
|
||||
}
|
||||
}
|
||||
obj = new Color(data);
|
||||
match++;
|
||||
} catch(err) {
|
||||
// json data failed to deserialize into [Number]
|
||||
errorMessages.push("Failed to construct [Number]: " + err)
|
||||
}
|
||||
|
||||
// Hex color string, such as #00FF00.
|
||||
try {
|
||||
// validate array of string
|
||||
if (!(typeof data === 'string')) {
|
||||
throw new Error("Invalid data. Must be string. Data: " + JSON.stringify(data));
|
||||
}
|
||||
if (!/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(data)) {
|
||||
throw new Error("Invalid string value in an array items. Must conform to /^#(?:[0-9a-fA-F]{3}){1,2}$/. Data: " + JSON.stringify(data));
|
||||
}
|
||||
if (data.length > 7 && data.length < 7) {
|
||||
throw new Error("Invalid string value in an array items. Max. length: 7. Min. length: 7. Data: " + JSON.stringify(data));
|
||||
}
|
||||
obj = new Color(data);
|
||||
match++;
|
||||
} catch(err) {
|
||||
// json data failed to deserialize into String
|
||||
errorMessages.push("Failed to construct String: " + err)
|
||||
}
|
||||
|
||||
if (match > 1) {
|
||||
throw new Error("Multiple matches found constructing `Color` with oneOf schemas String, [Number]. JSON data: " + JSON.stringify(data));
|
||||
} else if (match === 0) {
|
||||
throw new Error("No match found constructing `Color` with oneOf schemas String, [Number]. Details: " +
|
||||
errorMessages.join(", "));
|
||||
} else { // only 1 match
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the actaul instance, which can be <code>String</code>, <code>[Number]</code>.
|
||||
* @return {(module:model/String|module:model/[Number])} The actual instance.
|
||||
*/
|
||||
getActualInstance() {
|
||||
return this.actualInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the actaul instance, which can be <code>String</code>, <code>[Number]</code>.
|
||||
* @param {(module:model/String|module:model/[Number])} obj The actual instance.
|
||||
*/
|
||||
setActualInstance(obj) {
|
||||
this.actualInstance = Color.constructFromObject(obj).getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JSON representation of the actual intance.
|
||||
* @return {string}
|
||||
*/
|
||||
toJSON = function(){
|
||||
return this.getActualInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Color.OneOf = ["String", "[Number]"];
|
||||
|
||||
export default Color;
|
||||
|
||||
105
samples/client/petstore/javascript-es6/src/model/DanishPig.js
Normal file
105
samples/client/petstore/javascript-es6/src/model/DanishPig.js
Normal file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
import ApiClient from '../ApiClient';
|
||||
|
||||
/**
|
||||
* The DanishPig model module.
|
||||
* @module model/DanishPig
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class DanishPig {
|
||||
/**
|
||||
* Constructs a new <code>DanishPig</code>.
|
||||
* @alias module:model/DanishPig
|
||||
* @param className {String}
|
||||
* @param size {Number}
|
||||
*/
|
||||
constructor(className, size) {
|
||||
|
||||
DanishPig.initialize(this, className, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the fields of this object.
|
||||
* This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
|
||||
* Only for internal use.
|
||||
*/
|
||||
static initialize(obj, className, size) {
|
||||
obj['className'] = className;
|
||||
obj['size'] = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>DanishPig</code> from a plain JavaScript object, optionally creating a new instance.
|
||||
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @param {module:model/DanishPig} obj Optional instance to populate.
|
||||
* @return {module:model/DanishPig} The populated <code>DanishPig</code> instance.
|
||||
*/
|
||||
static constructFromObject(data, obj) {
|
||||
if (data) {
|
||||
obj = obj || new DanishPig();
|
||||
|
||||
if (data.hasOwnProperty('className')) {
|
||||
obj['className'] = ApiClient.convertToType(data['className'], 'String');
|
||||
}
|
||||
if (data.hasOwnProperty('size')) {
|
||||
obj['size'] = ApiClient.convertToType(data['size'], 'Number');
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>DanishPig</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>DanishPig</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// check to make sure all required properties are present in the JSON string
|
||||
for (const property of DanishPig.RequiredProperties) {
|
||||
if (!data[property]) {
|
||||
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['className'] && !(typeof data['className'] === 'string' || data['className'] instanceof String)) {
|
||||
throw new Error("Expected the field `className` to be a primitive type in the JSON string but got " + data['className']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
DanishPig.RequiredProperties = ["className", "size"];
|
||||
|
||||
/**
|
||||
* @member {String} className
|
||||
*/
|
||||
DanishPig.prototype['className'] = undefined;
|
||||
|
||||
/**
|
||||
* @member {Number} size
|
||||
*/
|
||||
DanishPig.prototype['size'] = undefined;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export default DanishPig;
|
||||
|
||||
@@ -54,9 +54,25 @@ class DeprecatedObject {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>DeprecatedObject</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>DeprecatedObject</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['name'] && !(typeof data['name'] === 'string' || data['name'] instanceof String)) {
|
||||
throw new Error("Expected the field `name` to be a primitive type in the JSON string but got " + data['name']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} name
|
||||
*/
|
||||
|
||||
@@ -63,9 +63,31 @@ class Dog {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Dog</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Dog</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// check to make sure all required properties are present in the JSON string
|
||||
for (const property of Dog.RequiredProperties) {
|
||||
if (!data[property]) {
|
||||
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['breed'] && !(typeof data['breed'] === 'string' || data['breed'] instanceof String)) {
|
||||
throw new Error("Expected the field `breed` to be a primitive type in the JSON string but got " + data['breed']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Dog.RequiredProperties = ["className"];
|
||||
|
||||
/**
|
||||
* @member {String} breed
|
||||
*/
|
||||
|
||||
@@ -54,9 +54,25 @@ class DogAllOf {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>DogAllOf</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>DogAllOf</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['breed'] && !(typeof data['breed'] === 'string' || data['breed'] instanceof String)) {
|
||||
throw new Error("Expected the field `breed` to be a primitive type in the JSON string but got " + data['breed']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} breed
|
||||
*/
|
||||
|
||||
@@ -57,9 +57,29 @@ class EnumArrays {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>EnumArrays</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>EnumArrays</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['just_symbol'] && !(typeof data['just_symbol'] === 'string' || data['just_symbol'] instanceof String)) {
|
||||
throw new Error("Expected the field `just_symbol` to be a primitive type in the JSON string but got " + data['just_symbol']);
|
||||
}
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['array_enum'])) {
|
||||
throw new Error("Expected the field `array_enum` to be an array in the JSON data but got " + data['array_enum']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {module:model/EnumArrays.JustSymbolEnum} just_symbol
|
||||
*/
|
||||
|
||||
@@ -81,9 +81,35 @@ class EnumTest {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>EnumTest</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>EnumTest</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// check to make sure all required properties are present in the JSON string
|
||||
for (const property of EnumTest.RequiredProperties) {
|
||||
if (!data[property]) {
|
||||
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['enum_string'] && !(typeof data['enum_string'] === 'string' || data['enum_string'] instanceof String)) {
|
||||
throw new Error("Expected the field `enum_string` to be a primitive type in the JSON string but got " + data['enum_string']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['enum_string_required'] && !(typeof data['enum_string_required'] === 'string' || data['enum_string_required'] instanceof String)) {
|
||||
throw new Error("Expected the field `enum_string_required` to be a primitive type in the JSON string but got " + data['enum_string_required']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
EnumTest.RequiredProperties = ["enum_string_required"];
|
||||
|
||||
/**
|
||||
* @member {module:model/EnumTest.EnumStringEnum} enum_string
|
||||
*/
|
||||
|
||||
@@ -55,9 +55,25 @@ class File {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>File</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>File</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['sourceURI'] && !(typeof data['sourceURI'] === 'string' || data['sourceURI'] instanceof String)) {
|
||||
throw new Error("Expected the field `sourceURI` to be a primitive type in the JSON string but got " + data['sourceURI']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test capitalization
|
||||
* @member {String} sourceURI
|
||||
|
||||
@@ -57,9 +57,35 @@ class FileSchemaTestClass {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>FileSchemaTestClass</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>FileSchemaTestClass</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// validate the optional field `file`
|
||||
if (data['file']) { // data not null
|
||||
File.validateJSON(data['file']);
|
||||
}
|
||||
if (data['files']) { // data not null
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['files'])) {
|
||||
throw new Error("Expected the field `files` to be an array in the JSON data but got " + data['files']);
|
||||
}
|
||||
// validate the optional field `files` (array)
|
||||
for (const item of data['files']) {
|
||||
File.validateJsonObject(item);
|
||||
};
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {File} file
|
||||
*/
|
||||
|
||||
@@ -54,9 +54,25 @@ class Foo {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Foo</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Foo</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['bar'] && !(typeof data['bar'] === 'string' || data['bar'] instanceof String)) {
|
||||
throw new Error("Expected the field `bar` to be a primitive type in the JSON string but got " + data['bar']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} bar
|
||||
* @default 'bar'
|
||||
|
||||
@@ -55,9 +55,25 @@ class FooGetDefaultResponse {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>FooGetDefaultResponse</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>FooGetDefaultResponse</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// validate the optional field `string`
|
||||
if (data['string']) { // data not null
|
||||
Foo.validateJSON(data['string']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {module:model/Foo} string
|
||||
*/
|
||||
|
||||
@@ -107,9 +107,47 @@ class FormatTest {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>FormatTest</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>FormatTest</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// check to make sure all required properties are present in the JSON string
|
||||
for (const property of FormatTest.RequiredProperties) {
|
||||
if (!data[property]) {
|
||||
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['string'] && !(typeof data['string'] === 'string' || data['string'] instanceof String)) {
|
||||
throw new Error("Expected the field `string` to be a primitive type in the JSON string but got " + data['string']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['uuid'] && !(typeof data['uuid'] === 'string' || data['uuid'] instanceof String)) {
|
||||
throw new Error("Expected the field `uuid` to be a primitive type in the JSON string but got " + data['uuid']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['password'] && !(typeof data['password'] === 'string' || data['password'] instanceof String)) {
|
||||
throw new Error("Expected the field `password` to be a primitive type in the JSON string but got " + data['password']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['pattern_with_digits'] && !(typeof data['pattern_with_digits'] === 'string' || data['pattern_with_digits'] instanceof String)) {
|
||||
throw new Error("Expected the field `pattern_with_digits` to be a primitive type in the JSON string but got " + data['pattern_with_digits']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['pattern_with_digits_and_delimiter'] && !(typeof data['pattern_with_digits_and_delimiter'] === 'string' || data['pattern_with_digits_and_delimiter'] instanceof String)) {
|
||||
throw new Error("Expected the field `pattern_with_digits_and_delimiter` to be a primitive type in the JSON string but got " + data['pattern_with_digits_and_delimiter']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
FormatTest.RequiredProperties = ["number", "byte", "date", "password"];
|
||||
|
||||
/**
|
||||
* @member {Number} integer
|
||||
*/
|
||||
|
||||
@@ -57,9 +57,29 @@ class HasOnlyReadOnly {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>HasOnlyReadOnly</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>HasOnlyReadOnly</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['bar'] && !(typeof data['bar'] === 'string' || data['bar'] instanceof String)) {
|
||||
throw new Error("Expected the field `bar` to be a primitive type in the JSON string but got " + data['bar']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['foo'] && !(typeof data['foo'] === 'string' || data['foo'] instanceof String)) {
|
||||
throw new Error("Expected the field `foo` to be a primitive type in the JSON string but got " + data['foo']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} bar
|
||||
*/
|
||||
|
||||
@@ -55,9 +55,25 @@ class HealthCheckResult {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>HealthCheckResult</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>HealthCheckResult</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['NullableMessage'] && !(typeof data['NullableMessage'] === 'string' || data['NullableMessage'] instanceof String)) {
|
||||
throw new Error("Expected the field `NullableMessage` to be a primitive type in the JSON string but got " + data['NullableMessage']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} NullableMessage
|
||||
*/
|
||||
|
||||
@@ -54,9 +54,25 @@ class List {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>List</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>List</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['123-list'] && !(typeof data['123-list'] === 'string' || data['123-list'] instanceof String)) {
|
||||
throw new Error("Expected the field `123-list` to be a primitive type in the JSON string but got " + data['123-list']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} 123-list
|
||||
*/
|
||||
|
||||
@@ -63,9 +63,21 @@ class MapTest {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>MapTest</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>MapTest</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Object.<String, Object.<String, String>>} map_map_of_string
|
||||
*/
|
||||
|
||||
@@ -61,9 +61,25 @@ class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>MixedPropertiesAndAdditionalPropertiesClass</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>MixedPropertiesAndAdditionalPropertiesClass</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['uuid'] && !(typeof data['uuid'] === 'string' || data['uuid'] instanceof String)) {
|
||||
throw new Error("Expected the field `uuid` to be a primitive type in the JSON string but got " + data['uuid']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} uuid
|
||||
*/
|
||||
|
||||
@@ -58,9 +58,25 @@ class Model200Response {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Model200Response</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Model200Response</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['class'] && !(typeof data['class'] === 'string' || data['class'] instanceof String)) {
|
||||
throw new Error("Expected the field `class` to be a primitive type in the JSON string but got " + data['class']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Number} name
|
||||
*/
|
||||
|
||||
@@ -66,9 +66,31 @@ class Name {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Name</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Name</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// check to make sure all required properties are present in the JSON string
|
||||
for (const property of Name.RequiredProperties) {
|
||||
if (!data[property]) {
|
||||
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['property'] && !(typeof data['property'] === 'string' || data['property'] instanceof String)) {
|
||||
throw new Error("Expected the field `property` to be a primitive type in the JSON string but got " + data['property']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Name.RequiredProperties = ["name"];
|
||||
|
||||
/**
|
||||
* @member {Number} name
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
import ApiClient from '../ApiClient';
|
||||
import Color from './Color';
|
||||
|
||||
/**
|
||||
* The NestedColor model module.
|
||||
* @module model/NestedColor
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class NestedColor {
|
||||
/**
|
||||
* Constructs a new <code>NestedColor</code>.
|
||||
* @alias module:model/NestedColor
|
||||
*/
|
||||
constructor() {
|
||||
|
||||
NestedColor.initialize(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the fields of this object.
|
||||
* This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
|
||||
* Only for internal use.
|
||||
*/
|
||||
static initialize(obj) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>NestedColor</code> from a plain JavaScript object, optionally creating a new instance.
|
||||
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @param {module:model/NestedColor} obj Optional instance to populate.
|
||||
* @return {module:model/NestedColor} The populated <code>NestedColor</code> instance.
|
||||
*/
|
||||
static constructFromObject(data, obj) {
|
||||
if (data) {
|
||||
obj = obj || new NestedColor();
|
||||
|
||||
if (data.hasOwnProperty('size')) {
|
||||
obj['size'] = ApiClient.convertToType(data['size'], 'Number');
|
||||
}
|
||||
if (data.hasOwnProperty('nested')) {
|
||||
obj['nested'] = Color.constructFromObject(data['nested']);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>NestedColor</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>NestedColor</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// validate the optional field `nested`
|
||||
if (data['nested']) { // data not null
|
||||
Color.validateJSON(data['nested']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Number} size
|
||||
*/
|
||||
NestedColor.prototype['size'] = undefined;
|
||||
|
||||
/**
|
||||
* @member {module:model/Color} nested
|
||||
*/
|
||||
NestedColor.prototype['nested'] = undefined;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export default NestedColor;
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
import ApiClient from '../ApiClient';
|
||||
import Pig from './Pig';
|
||||
|
||||
/**
|
||||
* The NestedOneOf model module.
|
||||
* @module model/NestedOneOf
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class NestedOneOf {
|
||||
/**
|
||||
* Constructs a new <code>NestedOneOf</code>.
|
||||
* @alias module:model/NestedOneOf
|
||||
*/
|
||||
constructor() {
|
||||
|
||||
NestedOneOf.initialize(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the fields of this object.
|
||||
* This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
|
||||
* Only for internal use.
|
||||
*/
|
||||
static initialize(obj) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>NestedOneOf</code> from a plain JavaScript object, optionally creating a new instance.
|
||||
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @param {module:model/NestedOneOf} obj Optional instance to populate.
|
||||
* @return {module:model/NestedOneOf} The populated <code>NestedOneOf</code> instance.
|
||||
*/
|
||||
static constructFromObject(data, obj) {
|
||||
if (data) {
|
||||
obj = obj || new NestedOneOf();
|
||||
|
||||
if (data.hasOwnProperty('size')) {
|
||||
obj['size'] = ApiClient.convertToType(data['size'], 'Number');
|
||||
}
|
||||
if (data.hasOwnProperty('nested_pig')) {
|
||||
obj['nested_pig'] = Pig.constructFromObject(data['nested_pig']);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>NestedOneOf</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>NestedOneOf</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// validate the optional field `nested_pig`
|
||||
if (data['nested_pig']) { // data not null
|
||||
Pig.validateJSON(data['nested_pig']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Number} size
|
||||
*/
|
||||
NestedOneOf.prototype['size'] = undefined;
|
||||
|
||||
/**
|
||||
* @member {module:model/Pig} nested_pig
|
||||
*/
|
||||
NestedOneOf.prototype['nested_pig'] = undefined;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export default NestedOneOf;
|
||||
|
||||
@@ -91,9 +91,37 @@ class NullableClass {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>NullableClass</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>NullableClass</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['string_prop'] && !(typeof data['string_prop'] === 'string' || data['string_prop'] instanceof String)) {
|
||||
throw new Error("Expected the field `string_prop` to be a primitive type in the JSON string but got " + data['string_prop']);
|
||||
}
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['array_nullable_prop'])) {
|
||||
throw new Error("Expected the field `array_nullable_prop` to be an array in the JSON data but got " + data['array_nullable_prop']);
|
||||
}
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['array_and_items_nullable_prop'])) {
|
||||
throw new Error("Expected the field `array_and_items_nullable_prop` to be an array in the JSON data but got " + data['array_and_items_nullable_prop']);
|
||||
}
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['array_items_nullable'])) {
|
||||
throw new Error("Expected the field `array_items_nullable` to be an array in the JSON data but got " + data['array_items_nullable']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Number} integer_prop
|
||||
*/
|
||||
|
||||
@@ -54,9 +54,21 @@ class NumberOnly {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>NumberOnly</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>NumberOnly</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Number} JustNumber
|
||||
*/
|
||||
|
||||
@@ -64,9 +64,33 @@ class ObjectWithDeprecatedFields {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>ObjectWithDeprecatedFields</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>ObjectWithDeprecatedFields</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['uuid'] && !(typeof data['uuid'] === 'string' || data['uuid'] instanceof String)) {
|
||||
throw new Error("Expected the field `uuid` to be a primitive type in the JSON string but got " + data['uuid']);
|
||||
}
|
||||
// validate the optional field `deprecatedRef`
|
||||
if (data['deprecatedRef']) { // data not null
|
||||
DeprecatedObject.validateJSON(data['deprecatedRef']);
|
||||
}
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['bars'])) {
|
||||
throw new Error("Expected the field `bars` to be an array in the JSON data but got " + data['bars']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} uuid
|
||||
*/
|
||||
|
||||
@@ -69,9 +69,25 @@ class Order {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Order</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Order</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['status'] && !(typeof data['status'] === 'string' || data['status'] instanceof String)) {
|
||||
throw new Error("Expected the field `status` to be a primitive type in the JSON string but got " + data['status']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Number} id
|
||||
*/
|
||||
|
||||
@@ -60,9 +60,25 @@ class OuterComposite {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>OuterComposite</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>OuterComposite</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['my_string'] && !(typeof data['my_string'] === 'string' || data['my_string'] instanceof String)) {
|
||||
throw new Error("Expected the field `my_string` to be a primitive type in the JSON string but got " + data['my_string']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Number} my_number
|
||||
*/
|
||||
|
||||
@@ -57,9 +57,27 @@ class OuterObjectWithEnumProperty {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>OuterObjectWithEnumProperty</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>OuterObjectWithEnumProperty</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// check to make sure all required properties are present in the JSON string
|
||||
for (const property of OuterObjectWithEnumProperty.RequiredProperties) {
|
||||
if (!data[property]) {
|
||||
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
OuterObjectWithEnumProperty.RequiredProperties = ["value"];
|
||||
|
||||
/**
|
||||
* @member {module:model/OuterEnumInteger} value
|
||||
*/
|
||||
|
||||
@@ -75,9 +75,53 @@ class Pet {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Pet</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Pet</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// check to make sure all required properties are present in the JSON string
|
||||
for (const property of Pet.RequiredProperties) {
|
||||
if (!data[property]) {
|
||||
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
|
||||
}
|
||||
}
|
||||
// validate the optional field `category`
|
||||
if (data['category']) { // data not null
|
||||
Category.validateJSON(data['category']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['name'] && !(typeof data['name'] === 'string' || data['name'] instanceof String)) {
|
||||
throw new Error("Expected the field `name` to be a primitive type in the JSON string but got " + data['name']);
|
||||
}
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['photoUrls'])) {
|
||||
throw new Error("Expected the field `photoUrls` to be an array in the JSON data but got " + data['photoUrls']);
|
||||
}
|
||||
if (data['tags']) { // data not null
|
||||
// ensure the json data is an array
|
||||
if (!Array.isArray(data['tags'])) {
|
||||
throw new Error("Expected the field `tags` to be an array in the JSON data but got " + data['tags']);
|
||||
}
|
||||
// validate the optional field `tags` (array)
|
||||
for (const item of data['tags']) {
|
||||
Tag.validateJsonObject(item);
|
||||
};
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['status'] && !(typeof data['status'] === 'string' || data['status'] instanceof String)) {
|
||||
throw new Error("Expected the field `status` to be a primitive type in the JSON string but got " + data['status']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Pet.RequiredProperties = ["name", "photoUrls"];
|
||||
|
||||
/**
|
||||
* @member {Number} id
|
||||
*/
|
||||
|
||||
123
samples/client/petstore/javascript-es6/src/model/Pig.js
Normal file
123
samples/client/petstore/javascript-es6/src/model/Pig.js
Normal file
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
import ApiClient from '../ApiClient';
|
||||
import BasquePig from './BasquePig';
|
||||
import DanishPig from './DanishPig';
|
||||
|
||||
/**
|
||||
* The Pig model module.
|
||||
* @module model/Pig
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class Pig {
|
||||
/**
|
||||
* Constructs a new <code>Pig</code>.
|
||||
* @alias module:model/Pig
|
||||
* @param {(module:model/BasquePig|module:model/DanishPig)} The actual instance to initialize Pig.
|
||||
*/
|
||||
constructor(obj = null) {
|
||||
this.actualInstance = obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <code>Pig</code> from a plain JavaScript object, optionally creating a new instance.
|
||||
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @param {module:model/Pig} obj Optional instance to populate.
|
||||
* @return {module:model/Pig} The populated <code>Pig</code> instance.
|
||||
*/
|
||||
static constructFromObject(data, obj) {
|
||||
if (!data) {
|
||||
return new Pig();
|
||||
}
|
||||
var match = 0;
|
||||
var errorMessages = [];
|
||||
try {
|
||||
// validate the JSON data
|
||||
BasquePig.validateJSON(data);
|
||||
// create BasquePig from JSON data
|
||||
obj = new Pig(BasquePig.constructFromObject(data));
|
||||
match++;
|
||||
} catch(err) {
|
||||
// json data failed to deserialize into BasquePig
|
||||
errorMessages.push("Failed to construct BasquePig: " + err)
|
||||
}
|
||||
|
||||
try {
|
||||
// validate the JSON data
|
||||
DanishPig.validateJSON(data);
|
||||
// create DanishPig from JSON data
|
||||
obj = new Pig(DanishPig.constructFromObject(data));
|
||||
match++;
|
||||
} catch(err) {
|
||||
// json data failed to deserialize into DanishPig
|
||||
errorMessages.push("Failed to construct DanishPig: " + err)
|
||||
}
|
||||
|
||||
if (match > 1) {
|
||||
throw new Error("Multiple matches found constructing `Pig` with oneOf schemas BasquePig, DanishPig. JSON data: " + JSON.stringify(data));
|
||||
} else if (match === 0) {
|
||||
throw new Error("No match found constructing `Pig` with oneOf schemas BasquePig, DanishPig. Details: " +
|
||||
errorMessages.join(", "));
|
||||
} else { // only 1 match
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the actaul instance, which can be <code>BasquePig</code>, <code>DanishPig</code>.
|
||||
* @return {(module:model/BasquePig|module:model/DanishPig)} The actual instance.
|
||||
*/
|
||||
getActualInstance() {
|
||||
return this.actualInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the actaul instance, which can be <code>BasquePig</code>, <code>DanishPig</code>.
|
||||
* @param {(module:model/BasquePig|module:model/DanishPig)} obj The actual instance.
|
||||
*/
|
||||
setActualInstance(obj) {
|
||||
this.actualInstance = Pig.constructFromObject(obj).getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JSON representation of the actual intance.
|
||||
* @return {string}
|
||||
*/
|
||||
toJSON = function(){
|
||||
return this.getActualInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @member {String} className
|
||||
*/
|
||||
Pig.prototype['className'] = undefined;
|
||||
|
||||
/**
|
||||
* @member {String} color
|
||||
*/
|
||||
Pig.prototype['color'] = undefined;
|
||||
|
||||
/**
|
||||
* @member {Number} size
|
||||
*/
|
||||
Pig.prototype['size'] = undefined;
|
||||
|
||||
|
||||
Pig.OneOf = ["BasquePig", "DanishPig"];
|
||||
|
||||
export default Pig;
|
||||
|
||||
@@ -57,9 +57,29 @@ class ReadOnlyFirst {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>ReadOnlyFirst</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>ReadOnlyFirst</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['bar'] && !(typeof data['bar'] === 'string' || data['bar'] instanceof String)) {
|
||||
throw new Error("Expected the field `bar` to be a primitive type in the JSON string but got " + data['bar']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['baz'] && !(typeof data['baz'] === 'string' || data['baz'] instanceof String)) {
|
||||
throw new Error("Expected the field `baz` to be a primitive type in the JSON string but got " + data['baz']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} bar
|
||||
*/
|
||||
|
||||
@@ -55,9 +55,21 @@ class Return {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Return</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Return</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Number} return
|
||||
*/
|
||||
|
||||
@@ -54,9 +54,21 @@ class SpecialModelName {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>SpecialModelName</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>SpecialModelName</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Number} $special[property.name]
|
||||
*/
|
||||
|
||||
@@ -57,9 +57,25 @@ class Tag {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>Tag</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>Tag</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['name'] && !(typeof data['name'] === 'string' || data['name'] instanceof String)) {
|
||||
throw new Error("Expected the field `name` to be a primitive type in the JSON string but got " + data['name']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Number} id
|
||||
*/
|
||||
|
||||
@@ -75,9 +75,45 @@ class User {
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>User</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>User</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['username'] && !(typeof data['username'] === 'string' || data['username'] instanceof String)) {
|
||||
throw new Error("Expected the field `username` to be a primitive type in the JSON string but got " + data['username']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['firstName'] && !(typeof data['firstName'] === 'string' || data['firstName'] instanceof String)) {
|
||||
throw new Error("Expected the field `firstName` to be a primitive type in the JSON string but got " + data['firstName']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['lastName'] && !(typeof data['lastName'] === 'string' || data['lastName'] instanceof String)) {
|
||||
throw new Error("Expected the field `lastName` to be a primitive type in the JSON string but got " + data['lastName']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['email'] && !(typeof data['email'] === 'string' || data['email'] instanceof String)) {
|
||||
throw new Error("Expected the field `email` to be a primitive type in the JSON string but got " + data['email']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['password'] && !(typeof data['password'] === 'string' || data['password'] instanceof String)) {
|
||||
throw new Error("Expected the field `password` to be a primitive type in the JSON string but got " + data['password']);
|
||||
}
|
||||
// ensure the json data is a string
|
||||
if (data['phone'] && !(typeof data['phone'] === 'string' || data['phone'] instanceof String)) {
|
||||
throw new Error("Expected the field `phone` to be a primitive type in the JSON string but got " + data['phone']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {Number} id
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user