diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java
index 7038400bda7..eac98040cc6 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java
@@ -852,8 +852,10 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
if (allDefinitions != null && codegenModel != null && codegenModel.parent != null && codegenModel.hasEnums) {
final Schema parentModel = allDefinitions.get(codegenModel.parentSchema);
- final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
- codegenModel = JavascriptClientCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
+ if (parentModel != null) {
+ final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
+ codegenModel = JavascriptClientCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
+ }
}
if (ModelUtils.isArraySchema(model)) {
ArraySchema am = (ArraySchema) model;
diff --git a/modules/openapi-generator/src/main/resources/Javascript/model.mustache b/modules/openapi-generator/src/main/resources/Javascript/model.mustache
index 3ddf83730f5..ab9f0f3e8fe 100644
--- a/modules/openapi-generator/src/main/resources/Javascript/model.mustache
+++ b/modules/openapi-generator/src/main/resources/Javascript/model.mustache
@@ -1,4 +1,28 @@
{{>licenseInfo}}
import ApiClient from '../ApiClient';
{{#imports}}import {{import}} from './{{import}}';
-{{/imports}}{{#models}}{{#model}}{{#isEnum}}{{>partial_model_enum_class}}{{/isEnum}}{{^isEnum}}{{>partial_model_generic}}{{/isEnum}}{{/model}}{{/models}}
+{{/imports}}
+{{#models}}
+{{#model}}
+{{#isEnum}}
+{{>partial_model_enum_class}}
+{{/isEnum}}
+{{^isEnum}}
+{{#oneOf}}
+{{#-first}}
+{{>partial_model_oneof}}
+{{/-first}}
+{{/oneOf}}
+{{^oneOf}}
+{{#anyOf}}
+{{#-first}}
+// TODO: add anyof model support
+{{/-first}}
+{{/anyOf}}
+{{^anyOf}}
+{{>partial_model_generic}}
+{{/anyOf}}
+{{/oneOf}}
+{{/isEnum}}
+{{/model}}
+{{/models}}
diff --git a/modules/openapi-generator/src/main/resources/Javascript/partial_model_generic.mustache b/modules/openapi-generator/src/main/resources/Javascript/partial_model_generic.mustache
index c367e4b8201..174a9a0064d 100644
--- a/modules/openapi-generator/src/main/resources/Javascript/partial_model_generic.mustache
+++ b/modules/openapi-generator/src/main/resources/Javascript/partial_model_generic.mustache
@@ -54,6 +54,80 @@ class {{classname}} {{#parent}}{{^parentModel}}{{#vendorExtensions.x-is-array}}e
return obj;
}
+ {{#emitJSDoc}}/**
+ * Validates the JSON data with respect to {{classname}}
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to {{classname}}
.
+ */{{/emitJSDoc}}
+ static validateJSON(data) {
+ {{#requiredVars}}
+ {{#-first}}
+ // check to make sure all required properties are present in the JSON string
+ for (const property of {{classname}}.RequiredProperties) {
+ if (!data[property]) {
+ throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
+ }
+ }
+ {{/-first}}
+ {{/requiredVars}}
+ {{#vars}}
+ {{#isArray}}
+ {{#items.isModel}}
+ {{#isRequired}}
+ // ensure the json data is an array
+ if (!Array.isArray(data['{{{baseName}}}'])) {
+ throw new Error("Expected the field `{{{baseName}}}` to be an array in the JSON data but got " + data['{{{baseName}}}']);
+ }
+ // validate the required field `{{{baseName}}}` (array)
+ for (const item of data['{{{baseName}}}']) {
+ {{{items.dataType}}}.validateJsonObject(item);
+ };
+ {{/isRequired}}
+ {{^isRequired}}
+ if (data['{{{baseName}}}']) { // data not null
+ // ensure the json data is an array
+ if (!Array.isArray(data['{{{baseName}}}'])) {
+ throw new Error("Expected the field `{{{baseName}}}` to be an array in the JSON data but got " + data['{{{baseName}}}']);
+ }
+ // validate the optional field `{{{baseName}}}` (array)
+ for (const item of data['{{{baseName}}}']) {
+ {{{items.dataType}}}.validateJsonObject(item);
+ };
+ }
+ {{/isRequired}}
+ {{/items.isModel}}
+ {{^items.isModel}}
+ // ensure the json data is an array
+ if (!Array.isArray(data['{{{baseName}}}'])) {
+ throw new Error("Expected the field `{{{baseName}}}` to be an array in the JSON data but got " + data['{{{baseName}}}']);
+ }
+ {{/items.isModel}}
+ {{/isArray}}
+ {{^isContainer}}
+ {{#isString}}
+ // ensure the json data is a string
+ if ({{^isRequired}}data['{{{baseName}}}']{{/isRequired}} && !(typeof data['{{{baseName}}}'] === 'string' || data['{{{baseName}}}'] instanceof String)) {
+ throw new Error("Expected the field `{{{baseName}}}` to be a primitive type in the JSON string but got " + data['{{{baseName}}}']);
+ }
+ {{/isString}}
+ {{#isModel}}
+ {{#isRequired}}
+ // validate the required field `{{{baseName}}}`
+ {{{dataType}}}.validateJSON(data['{{{baseName}}}']);
+ {{/isRequired}}
+ {{^isRequired}}
+ // validate the optional field `{{{baseName}}}`
+ if (data['{{{baseName}}}']) { // data not null
+ {{{dataType}}}.validateJSON(data['{{{baseName}}}']);
+ }
+ {{/isRequired}}
+ {{/isModel}}
+ {{/isContainer}}
+ {{/vars}}
+
+ return true;
+ }
+
{{#emitModelMethods}}{{#vars}}{{#emitJSDoc}}/**{{#description}}
* Returns {{{.}}}{{/description}}{{#minimum}}
* minimum: {{.}}{{/minimum}}{{#maximum}}
@@ -74,6 +148,8 @@ class {{classname}} {{#parent}}{{^parentModel}}{{#vendorExtensions.x-is-array}}e
{{/vars}}{{/emitModelMethods}}{{/model}}
}
+{{#requiredVars}}{{#-first}}{{classname}}.RequiredProperties = [{{/-first}}"{{{baseName}}}"{{^-last}}, {{/-last}}{{#-last}}];{{/-last}}{{/requiredVars}}
+
{{#vars}}{{#emitJSDoc}}/**{{#description}}
* {{{.}}}{{/description}}
* @member {{=< >=}}{<&vendorExtensions.x-jsdoc-type>}<={{ }}=> {{baseName}}{{#defaultValue}}
diff --git a/modules/openapi-generator/src/main/resources/Javascript/partial_model_oneof.mustache b/modules/openapi-generator/src/main/resources/Javascript/partial_model_oneof.mustache
new file mode 100644
index 00000000000..4a4e5982f11
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/Javascript/partial_model_oneof.mustache
@@ -0,0 +1,265 @@
+
+{{#emitJSDoc}}
+/**
+ * The {{classname}} model module.
+ * @module {{#invokerPackage}}{{.}}/{{/invokerPackage}}{{#modelPackage}}{{.}}/{{/modelPackage}}{{classname}}
+ * @version {{projectVersion}}
+ */
+{{/emitJSDoc}}
+class {{classname}} {
+ {{#emitJSDoc}}/**
+ * Constructs a new {{classname}}
.{{#description}}
+ * {{.}}{{/description}}
+ * @alias module:{{#invokerPackage}}{{.}}/{{/invokerPackage}}{{#modelPackage}}{{.}}/{{/modelPackage}}{{classname}}
+ * @param {{=< >=}}{(<#oneOf>module:<#invokerPackage>/<#modelPackage>/<&.><^-last>|-last>)}<={{ }}=> The actual instance to initialize {{classname}}.
+ */
+ {{/emitJSDoc}}
+ constructor(obj = null) {
+ this.actualInstance = obj;
+ }
+
+ {{#emitJSDoc}}
+ /**
+ * Constructs a {{classname}}
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
if supplied or a new instance if not.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @param {{=< >=}}{module:<#invokerPackage>/<#modelPackage>/}<={{ }}=> obj Optional instance to populate.
+ * @return {{=< >=}}{module:<#invokerPackage>/<#modelPackage>/}<={{ }}=> The populated {{classname}}
instance.
+ */
+ {{/emitJSDoc}}
+ static constructFromObject(data, obj) {
+ if (!data) {
+ return new {{classname}}();
+ }
+ var match = 0;
+ var errorMessages = [];
+ {{#composedSchemas.oneOf}}
+ {{#description}}
+ // {{{description}}}
+ {{/description}}
+ try {
+ {{#isPrimitiveType}}
+ {{#isArray}}
+ // validate array data type
+ if (!Array.isArray(data)) {
+ throw new Error("Invalid data type. Expecting array. Data: " + data);
+ }
+ {{#minItems}}
+ {{#maxItems}}
+ if (data.length > {{{maxItems}}} || data.length < {{{minItems}}}) {
+ throw new Error("Invalid array size. Minimim: {{minItems}}. Maximum: {{maxItems}}. Data: " + data);
+ }
+ {{/maxItems}}
+ {{^maxItems}}
+ if (data.length < {{{minItems}}}) {
+ throw new Error("Invalid array size. Minimim: {{minItems}}. Data: " + data);
+ }
+ {{/maxItems}}
+ {{/minItems}}
+ {{^minItems}}
+ {{#maxItems}}
+ if (data.length > {{{maxItems}}}) {
+ throw new Error("Invalid array size. Maximum: {{maxItems}}. Data: " + data);
+ }
+ {{/maxItems}}
+ {{/minItems}}
+ {{#items.isInteger}}
+ // 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);
+ }
+ {{#items.maximum}}
+ {{#items.minimum}}
+ if (item > {{items.maximum}} || item < {{items.minimum}}) {
+ throw new Error("Invalid integer value in an array items. Max.: {{items.maximum}}. Min.: {{items.minimum}}. Data: " + data);
+ }
+ {{/items.minimum}}
+ {{^items.minimum}}
+ if (item > {{items.maximum}}) {
+ throw new Error("Invalid integer value in an array items. Max.: {{items.maximum}}. Data: " + data);
+ }
+ {{/items.minimum}}
+ {{/items.maximum}}
+ {{^items.maximum}}
+ {{#items.minimum}}
+ if (item < {{items.minimum}}) {
+ throw new Error("Invalid integer value in an array items. Min.: {{items.minimum}}. Data: " + data);
+ }
+ {{/items.minimum}}
+ {{/items.maximum}}
+ }
+ {{/items.isInteger}}
+ {{#items.isString}}
+ // validate array of string
+ for (const item of data) {
+ if (!(typeof item === 'number' && item % 1 === 0)) {
+ throw new Error("Invalid array items. Must be string. Data: " + data);
+ }
+ {{#items.pattern}}
+ if (!{{{items.pattern}}}.test(item)) {
+ throw new Error("Invalid string value in an array items. Must conform to {{{items.pattern}}}. Data: " + item);
+ }
+ {{/items.pattern}}
+ {{#items.minLength}}
+ {{#items.maxLength}}
+ if (item.length > {{items.maxLength}} && item.length < {{items.minLength}}) {
+ throw new Error("Invalid string value in an array items. Max. length: {{{items.maxLength}}}. Min. length: {{{items.minLength}}}. Data: " + item);
+ }
+ {{/items.maxLength}}
+ {{^items.maxLength}}
+ if (item.length < {{items.minLength}}) {
+ throw new Error("Invalid string value in an array items. Min. length: {{{items.minLength}}}. Data: " + item);
+ }
+ {{/items.maxLength}}
+ {{/items.minLength}}
+ {{^items.minLength}}
+ {{#items.maxLength}}
+ if (item.length > {{items.maxLength}}) {
+ throw new Error("Invalid string value in an array items. Max. length: {{{items.maxLength}}}. Data: " + item)
+ }
+ {{/items.maxLength}}
+ {{/items.minLength}}
+ }
+ {{/items.isString}}
+ {{#items.isNumber}}
+ // validate array of string
+ for (const item of data) {
+ if (!(typeof data === 'number' && data % 1 != 0)) {
+ throw new Error("Invalid array items. Must be number. Data: " + JSON.stringify(data));
+ }
+ }
+ {{/items.isNumber}}
+ {{/isArray}}
+ {{^isArray}}
+ {{#isInteger}}
+ // validate array of integer
+ if (!(typeof data === 'number' && data % 1 === 0)) {
+ throw new Error("Invalid array items. Must be integer. Data: " + JSON.stringify(data));
+ }
+ {{#maximum}}
+ {{#minimum}}
+ if (data > {{maximum}} || data < {{minimum}}) {
+ throw new Error("Invalid integer value in an array items. Max.: {{maximum}}. Min.: {{minimum}}. Data: " + JSON.stringify(data));
+ }
+ {{/minimum}}
+ {{^minimum}}
+ if (data > {{maximum}}) {
+ throw new Error("Invalid integer value in an array items. Max.: {{maximum}}. Data: " + JSON.stringify(data));
+ }
+ {{/minimum}}
+ {{/maximum}}
+ {{^maximum}}
+ {{#minimum}}
+ if (data < {{minimum}}) {
+ throw new Error("Invalid integer value in an array items. Min.: {{minimum}}. Data: " + JSON.stringify(data));
+ }
+ {{/minimum}}
+ {{/maximum}}
+ {{/isInteger}}
+ {{#isString}}
+ // validate array of string
+ if (!(typeof data === 'string')) {
+ throw new Error("Invalid data. Must be string. Data: " + JSON.stringify(data));
+ }
+ {{#pattern}}
+ if (!{{{pattern}}}.test(data)) {
+ throw new Error("Invalid string value in an array items. Must conform to {{{.}}}. Data: " + JSON.stringify(data));
+ }
+ {{/pattern}}
+ {{#minLength}}
+ {{#maxLength}}
+ if (data.length > {{maxLength}} && data.length < {{minLength}}) {
+ throw new Error("Invalid string value in an array items. Max. length: {{{maxLength}}}. Min. length: {{{minLength}}}. Data: " + JSON.stringify(data));
+ }
+ {{/maxLength}}
+ {{^maxLength}}
+ if (data.length < {{minLength}}) {
+ throw new Error("Invalid string value in an array items. Min. length: {{{minLength}}}. Data: " + data);
+ }
+ {{/maxLength}}
+ {{/minLength}}
+ {{^minLength}}
+ {{#maxLength}}
+ if (data.length > {{maxLength}}) {
+ throw new Error("Invalid string value in an array items. Max. length: {{{maxLength}}}. Data: " + JSON.stringify(data));
+ }
+ {{/maxLength}}
+ {{/minLength}}
+ {{/isString}}
+ {{#isNumber}}
+ // validate array of string
+ if (!(typeof data === 'number' && data % 1 != 0)) {
+ throw new Error("Invalid array items. Must be number. Data: " + JSON.stringify(data));
+ }
+ {{/isNumber}}
+ {{/isArray}}
+ obj = new {{classname}}(data);
+ {{/isPrimitiveType}}
+ {{^isPrimitiveType}}
+ // validate the JSON data
+ {{{dataType}}}.validateJSON(data);
+ // create {{{dataType}}} from JSON data
+ obj = new {{classname}}({{{dataType}}}.constructFromObject(data));
+ {{/isPrimitiveType}}
+ match++;
+ } catch(err) {
+ // json data failed to deserialize into {{{dataType}}}
+ errorMessages.push("Failed to construct {{{dataType}}}: " + err)
+ }
+
+ {{/composedSchemas.oneOf}}
+ if (match > 1) {
+ throw new Error("Multiple matches found constructing `{{{classname}}}` with oneOf schemas {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. JSON data: " + JSON.stringify(data));
+ } else if (match === 0) {
+ throw new Error("No match found constructing `{{{classname}}}` with oneOf schemas {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Details: " +
+ errorMessages.join(", "));
+ } else { // only 1 match
+ return obj;
+ }
+ }
+
+ {{#emitJSDoc}}
+ /**
+ * Gets the actaul instance, which can be {{#oneOf}}{{{.}}}
{{^-last}}, {{/-last}}{{/oneOf}}.
+ * @return {{=< >=}}{(<#oneOf>module:<#invokerPackage>/<#modelPackage>/<&.><^-last>|-last>)}<={{ }}=> The actual instance.
+ */
+ {{/emitJSDoc}}
+ getActualInstance() {
+ return this.actualInstance;
+ }
+
+ {{#emitJSDoc}}
+ /**
+ * Sets the actaul instance, which can be {{#oneOf}}{{{.}}}
{{^-last}}, {{/-last}}{{/oneOf}}.
+ * @param {{=< >=}}{(<#oneOf>module:<#invokerPackage>/<#modelPackage>/<&.><^-last>|-last>)}<={{ }}=> obj The actual instance.
+ */
+ {{/emitJSDoc}}
+ setActualInstance(obj) {
+ this.actualInstance = {{classname}}.constructFromObject(obj).getActualInstance();
+ }
+
+ {{#emitJSDoc}}
+ /**
+ * Returns the JSON representation of the actual intance.
+ * @return {string}
+ */
+ {{/emitJSDoc}}
+ toJSON = function(){
+ return this.getActualInstance();
+ }
+
+}
+
+{{#vars}}{{#emitJSDoc}}/**{{#description}}
+ * {{{.}}}{{/description}}
+ * @member {{=< >=}}{<&vendorExtensions.x-jsdoc-type>}<={{ }}=> {{baseName}}{{#defaultValue}}
+ * @default {{{.}}}{{/defaultValue}}
+ */{{/emitJSDoc}}
+{{classname}}.prototype['{{baseName}}'] = {{{defaultValue}}}{{^defaultValue}}undefined{{/defaultValue}};
+
+{{/vars}}
+
+{{classname}}.OneOf = [{{#oneOf}}"{{{.}}}"{{^-last}}, {{/-last}}{{/oneOf}}];
+
+export default {{classname}};
diff --git a/modules/openapi-generator/src/test/resources/3_0/javascript/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/javascript/petstore-with-fake-endpoints-models-for-testing.yaml
index 772d09dd0b6..fadeb02edb7 100644
--- a/modules/openapi-generator/src/test/resources/3_0/javascript/petstore-with-fake-endpoints-models-for-testing.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/javascript/petstore-with-fake-endpoints-models-for-testing.yaml
@@ -1908,3 +1908,72 @@ components:
deprecated: true
items:
$ref: '#/components/schemas/Bar'
+ Pig:
+ nullable: true
+ oneOf:
+ - $ref: '#/components/schemas/BasquePig'
+ - $ref: '#/components/schemas/DanishPig'
+ BasquePig:
+ type: object
+ properties:
+ className:
+ type: string
+ color:
+ type: string
+ required:
+ - className
+ - color
+ DanishPig:
+ type: object
+ properties:
+ className:
+ type: string
+ size:
+ type: integer
+ required:
+ - className
+ - size
+ NestedOneOf:
+ type: object
+ properties:
+ size:
+ type: integer
+ nested_pig:
+ $ref: '#/components/schemas/Pig'
+ NestedColor:
+ type: object
+ properties:
+ size:
+ type: integer
+ nested:
+ $ref: '#/components/schemas/Color'
+ RgbColor:
+ description: RGB three element array with values 0-255.
+ type: array
+ items:
+ type: integer
+ minimum: 0
+ maximum: 255
+ minItems: 3
+ maxItems: 3
+ RgbaColor:
+ description: RGBA four element array with values 0-255.
+ type: array
+ items:
+ type: integer
+ minimum: 0
+ maximum: 255
+ minItems: 4
+ maxItems: 4
+ HexColor:
+ description: 'Hex color string, such as #00FF00.'
+ type: string
+ pattern: ^#(?:[0-9a-fA-F]{3}){1,2}$
+ minLength: 7
+ maxLength: 7
+ Color:
+ description: RGB array, RGBA array, or hex string.
+ oneOf:
+ - $ref: '#/components/schemas/RgbColor'
+ - $ref: '#/components/schemas/RgbaColor'
+ - $ref: '#/components/schemas/HexColor'
diff --git a/samples/client/petstore/javascript-apollo/.openapi-generator/FILES b/samples/client/petstore/javascript-apollo/.openapi-generator/FILES
index 0440bb2716c..f83260318a5 100644
--- a/samples/client/petstore/javascript-apollo/.openapi-generator/FILES
+++ b/samples/client/petstore/javascript-apollo/.openapi-generator/FILES
@@ -9,12 +9,15 @@ docs/ApiResponse.md
docs/ArrayOfArrayOfNumberOnly.md
docs/ArrayOfNumberOnly.md
docs/ArrayTest.md
+docs/BasquePig.md
docs/Capitalization.md
docs/Cat.md
docs/CatAllOf.md
docs/Category.md
docs/ClassModel.md
docs/Client.md
+docs/Color.md
+docs/DanishPig.md
docs/DefaultApi.md
docs/DeprecatedObject.md
docs/Dog.md
@@ -36,6 +39,8 @@ docs/MapTest.md
docs/MixedPropertiesAndAdditionalPropertiesClass.md
docs/Model200Response.md
docs/Name.md
+docs/NestedColor.md
+docs/NestedOneOf.md
docs/NullableClass.md
docs/NumberOnly.md
docs/ObjectWithDeprecatedFields.md
@@ -48,6 +53,7 @@ docs/OuterEnumIntegerDefaultValue.md
docs/OuterObjectWithEnumProperty.md
docs/Pet.md
docs/PetApi.md
+docs/Pig.md
docs/ReadOnlyFirst.md
docs/Return.md
docs/SpecialModelName.md
@@ -73,12 +79,15 @@ src/model/ApiResponse.js
src/model/ArrayOfArrayOfNumberOnly.js
src/model/ArrayOfNumberOnly.js
src/model/ArrayTest.js
+src/model/BasquePig.js
src/model/Capitalization.js
src/model/Cat.js
src/model/CatAllOf.js
src/model/Category.js
src/model/ClassModel.js
src/model/Client.js
+src/model/Color.js
+src/model/DanishPig.js
src/model/DeprecatedObject.js
src/model/Dog.js
src/model/DogAllOf.js
@@ -97,6 +106,8 @@ src/model/MapTest.js
src/model/MixedPropertiesAndAdditionalPropertiesClass.js
src/model/Model200Response.js
src/model/Name.js
+src/model/NestedColor.js
+src/model/NestedOneOf.js
src/model/NullableClass.js
src/model/NumberOnly.js
src/model/ObjectWithDeprecatedFields.js
@@ -108,6 +119,7 @@ src/model/OuterEnumInteger.js
src/model/OuterEnumIntegerDefaultValue.js
src/model/OuterObjectWithEnumProperty.js
src/model/Pet.js
+src/model/Pig.js
src/model/ReadOnlyFirst.js
src/model/Return.js
src/model/SpecialModelName.js
diff --git a/samples/client/petstore/javascript-apollo/README.md b/samples/client/petstore/javascript-apollo/README.md
index 2f7325ceebb..a6a90be126d 100644
--- a/samples/client/petstore/javascript-apollo/README.md
+++ b/samples/client/petstore/javascript-apollo/README.md
@@ -171,12 +171,15 @@ Class | Method | HTTP request | Description
- [OpenApiPetstore.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
- [OpenApiPetstore.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [OpenApiPetstore.ArrayTest](docs/ArrayTest.md)
+ - [OpenApiPetstore.BasquePig](docs/BasquePig.md)
- [OpenApiPetstore.Capitalization](docs/Capitalization.md)
- [OpenApiPetstore.Cat](docs/Cat.md)
- [OpenApiPetstore.CatAllOf](docs/CatAllOf.md)
- [OpenApiPetstore.Category](docs/Category.md)
- [OpenApiPetstore.ClassModel](docs/ClassModel.md)
- [OpenApiPetstore.Client](docs/Client.md)
+ - [OpenApiPetstore.Color](docs/Color.md)
+ - [OpenApiPetstore.DanishPig](docs/DanishPig.md)
- [OpenApiPetstore.DeprecatedObject](docs/DeprecatedObject.md)
- [OpenApiPetstore.Dog](docs/Dog.md)
- [OpenApiPetstore.DogAllOf](docs/DogAllOf.md)
@@ -195,6 +198,8 @@ Class | Method | HTTP request | Description
- [OpenApiPetstore.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
- [OpenApiPetstore.Model200Response](docs/Model200Response.md)
- [OpenApiPetstore.Name](docs/Name.md)
+ - [OpenApiPetstore.NestedColor](docs/NestedColor.md)
+ - [OpenApiPetstore.NestedOneOf](docs/NestedOneOf.md)
- [OpenApiPetstore.NullableClass](docs/NullableClass.md)
- [OpenApiPetstore.NumberOnly](docs/NumberOnly.md)
- [OpenApiPetstore.ObjectWithDeprecatedFields](docs/ObjectWithDeprecatedFields.md)
@@ -206,6 +211,7 @@ Class | Method | HTTP request | Description
- [OpenApiPetstore.OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md)
- [OpenApiPetstore.OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md)
- [OpenApiPetstore.Pet](docs/Pet.md)
+ - [OpenApiPetstore.Pig](docs/Pig.md)
- [OpenApiPetstore.ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [OpenApiPetstore.Return](docs/Return.md)
- [OpenApiPetstore.SpecialModelName](docs/SpecialModelName.md)
diff --git a/samples/client/petstore/javascript-apollo/docs/BasquePig.md b/samples/client/petstore/javascript-apollo/docs/BasquePig.md
new file mode 100644
index 00000000000..77d1e74bc71
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/docs/BasquePig.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.BasquePig
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**className** | **String** | |
+**color** | **String** | |
+
+
diff --git a/samples/client/petstore/javascript-apollo/docs/Color.md b/samples/client/petstore/javascript-apollo/docs/Color.md
new file mode 100644
index 00000000000..5f0e6f0dfba
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/docs/Color.md
@@ -0,0 +1,8 @@
+# OpenApiPetstore.Color
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+
diff --git a/samples/client/petstore/javascript-apollo/docs/DanishPig.md b/samples/client/petstore/javascript-apollo/docs/DanishPig.md
new file mode 100644
index 00000000000..7de3e60db36
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/docs/DanishPig.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.DanishPig
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**className** | **String** | |
+**size** | **Number** | |
+
+
diff --git a/samples/client/petstore/javascript-apollo/docs/NestedColor.md b/samples/client/petstore/javascript-apollo/docs/NestedColor.md
new file mode 100644
index 00000000000..aea6b444942
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/docs/NestedColor.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.NestedColor
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**size** | **Number** | | [optional]
+**nested** | [**Color**](Color.md) | | [optional]
+
+
diff --git a/samples/client/petstore/javascript-apollo/docs/NestedOneOf.md b/samples/client/petstore/javascript-apollo/docs/NestedOneOf.md
new file mode 100644
index 00000000000..b5228e89c70
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/docs/NestedOneOf.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.NestedOneOf
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**size** | **Number** | | [optional]
+**nestedPig** | [**Pig**](Pig.md) | | [optional]
+
+
diff --git a/samples/client/petstore/javascript-apollo/docs/Pig.md b/samples/client/petstore/javascript-apollo/docs/Pig.md
new file mode 100644
index 00000000000..a94e1687cc5
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/docs/Pig.md
@@ -0,0 +1,11 @@
+# OpenApiPetstore.Pig
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**className** | **String** | |
+**color** | **String** | |
+**size** | **Number** | |
+
+
diff --git a/samples/client/petstore/javascript-apollo/src/index.js b/samples/client/petstore/javascript-apollo/src/index.js
index 474899d9c51..a95a17ec1b0 100644
--- a/samples/client/petstore/javascript-apollo/src/index.js
+++ b/samples/client/petstore/javascript-apollo/src/index.js
@@ -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}
diff --git a/samples/client/petstore/javascript-apollo/src/model/AdditionalPropertiesClass.js b/samples/client/petstore/javascript-apollo/src/model/AdditionalPropertiesClass.js
index d6d83cca284..3849c00c595 100644
--- a/samples/client/petstore/javascript-apollo/src/model/AdditionalPropertiesClass.js
+++ b/samples/client/petstore/javascript-apollo/src/model/AdditionalPropertiesClass.js
@@ -57,9 +57,21 @@ class AdditionalPropertiesClass {
return obj;
}
+ /**
+ * Validates the JSON data with respect to AdditionalPropertiesClass
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to AdditionalPropertiesClass
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Object.} map_property
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Animal.js b/samples/client/petstore/javascript-apollo/src/model/Animal.js
index 7cb9017160b..27c6975b599 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Animal.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Animal.js
@@ -59,9 +59,35 @@ class Animal {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Animal
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Animal
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/ApiResponse.js b/samples/client/petstore/javascript-apollo/src/model/ApiResponse.js
index f5af17fdf82..6db561122f1 100644
--- a/samples/client/petstore/javascript-apollo/src/model/ApiResponse.js
+++ b/samples/client/petstore/javascript-apollo/src/model/ApiResponse.js
@@ -60,9 +60,29 @@ class ApiResponse {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ApiResponse
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ApiResponse
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/ArrayOfArrayOfNumberOnly.js b/samples/client/petstore/javascript-apollo/src/model/ArrayOfArrayOfNumberOnly.js
index eadd7db414b..461c6b5b35b 100644
--- a/samples/client/petstore/javascript-apollo/src/model/ArrayOfArrayOfNumberOnly.js
+++ b/samples/client/petstore/javascript-apollo/src/model/ArrayOfArrayOfNumberOnly.js
@@ -54,9 +54,25 @@ class ArrayOfArrayOfNumberOnly {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ArrayOfArrayOfNumberOnly
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ArrayOfArrayOfNumberOnly
.
+ */
+ 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.>} ArrayArrayNumber
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/ArrayOfNumberOnly.js b/samples/client/petstore/javascript-apollo/src/model/ArrayOfNumberOnly.js
index 1145a62630d..4c2513c1076 100644
--- a/samples/client/petstore/javascript-apollo/src/model/ArrayOfNumberOnly.js
+++ b/samples/client/petstore/javascript-apollo/src/model/ArrayOfNumberOnly.js
@@ -54,9 +54,25 @@ class ArrayOfNumberOnly {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ArrayOfNumberOnly
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ArrayOfNumberOnly
.
+ */
+ 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.} ArrayNumber
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/ArrayTest.js b/samples/client/petstore/javascript-apollo/src/model/ArrayTest.js
index 18bc925308a..3fc3c9b7f92 100644
--- a/samples/client/petstore/javascript-apollo/src/model/ArrayTest.js
+++ b/samples/client/petstore/javascript-apollo/src/model/ArrayTest.js
@@ -61,9 +61,33 @@ class ArrayTest {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ArrayTest
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ArrayTest
.
+ */
+ 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.} array_of_string
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/BasquePig.js b/samples/client/petstore/javascript-apollo/src/model/BasquePig.js
new file mode 100644
index 00000000000..dc26c47c4fb
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/src/model/BasquePig.js
@@ -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 BasquePig
.
+ * @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 BasquePig
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 BasquePig
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 BasquePig
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to BasquePig
.
+ */
+ 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;
+
diff --git a/samples/client/petstore/javascript-apollo/src/model/Capitalization.js b/samples/client/petstore/javascript-apollo/src/model/Capitalization.js
index 63b14361fee..cf4ef4348ac 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Capitalization.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Capitalization.js
@@ -69,9 +69,45 @@ class Capitalization {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Capitalization
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Capitalization
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Cat.js b/samples/client/petstore/javascript-apollo/src/model/Cat.js
index d18ce94e70e..203a652cfc4 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Cat.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Cat.js
@@ -63,9 +63,27 @@ class Cat {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Cat
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Cat
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/CatAllOf.js b/samples/client/petstore/javascript-apollo/src/model/CatAllOf.js
index c71ea7129b0..8c0d5bfbbd4 100644
--- a/samples/client/petstore/javascript-apollo/src/model/CatAllOf.js
+++ b/samples/client/petstore/javascript-apollo/src/model/CatAllOf.js
@@ -54,9 +54,21 @@ class CatAllOf {
return obj;
}
+ /**
+ * Validates the JSON data with respect to CatAllOf
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to CatAllOf
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Boolean} declawed
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Category.js b/samples/client/petstore/javascript-apollo/src/model/Category.js
index 557e8e18620..fc304998f40 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Category.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Category.js
@@ -59,9 +59,31 @@ class Category {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Category
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Category
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/ClassModel.js b/samples/client/petstore/javascript-apollo/src/model/ClassModel.js
index ee1f1417777..ba614443ebf 100644
--- a/samples/client/petstore/javascript-apollo/src/model/ClassModel.js
+++ b/samples/client/petstore/javascript-apollo/src/model/ClassModel.js
@@ -55,9 +55,25 @@ class ClassModel {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ClassModel
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ClassModel
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Client.js b/samples/client/petstore/javascript-apollo/src/model/Client.js
index 8521c85043b..4089ff37ee6 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Client.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Client.js
@@ -54,9 +54,25 @@ class Client {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Client
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Client
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Color.js b/samples/client/petstore/javascript-apollo/src/model/Color.js
new file mode 100644
index 00000000000..759e5df97af
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/src/model/Color.js
@@ -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 Color
.
+ * 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 Color
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 Color
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 String
, [Number]
.
+ * @return {(module:model/String|module:model/[Number])} The actual instance.
+ */
+ getActualInstance() {
+ return this.actualInstance;
+ }
+
+ /**
+ * Sets the actaul instance, which can be String
, [Number]
.
+ * @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;
+
diff --git a/samples/client/petstore/javascript-apollo/src/model/DanishPig.js b/samples/client/petstore/javascript-apollo/src/model/DanishPig.js
new file mode 100644
index 00000000000..4023e9d637f
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/src/model/DanishPig.js
@@ -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 DanishPig
.
+ * @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 DanishPig
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 DanishPig
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 DanishPig
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to DanishPig
.
+ */
+ 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;
+
diff --git a/samples/client/petstore/javascript-apollo/src/model/DeprecatedObject.js b/samples/client/petstore/javascript-apollo/src/model/DeprecatedObject.js
index c3298d50200..d7c874345f1 100644
--- a/samples/client/petstore/javascript-apollo/src/model/DeprecatedObject.js
+++ b/samples/client/petstore/javascript-apollo/src/model/DeprecatedObject.js
@@ -54,9 +54,25 @@ class DeprecatedObject {
return obj;
}
+ /**
+ * Validates the JSON data with respect to DeprecatedObject
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to DeprecatedObject
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Dog.js b/samples/client/petstore/javascript-apollo/src/model/Dog.js
index b101feecd32..dd3f1ebb509 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Dog.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Dog.js
@@ -63,9 +63,31 @@ class Dog {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Dog
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Dog
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/DogAllOf.js b/samples/client/petstore/javascript-apollo/src/model/DogAllOf.js
index 58ecede6126..beb42db2ec8 100644
--- a/samples/client/petstore/javascript-apollo/src/model/DogAllOf.js
+++ b/samples/client/petstore/javascript-apollo/src/model/DogAllOf.js
@@ -54,9 +54,25 @@ class DogAllOf {
return obj;
}
+ /**
+ * Validates the JSON data with respect to DogAllOf
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to DogAllOf
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/EnumArrays.js b/samples/client/petstore/javascript-apollo/src/model/EnumArrays.js
index 7fe64e3111a..2289689e349 100644
--- a/samples/client/petstore/javascript-apollo/src/model/EnumArrays.js
+++ b/samples/client/petstore/javascript-apollo/src/model/EnumArrays.js
@@ -57,9 +57,29 @@ class EnumArrays {
return obj;
}
+ /**
+ * Validates the JSON data with respect to EnumArrays
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to EnumArrays
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/EnumTest.js b/samples/client/petstore/javascript-apollo/src/model/EnumTest.js
index dc684b7c26b..b1556a0613f 100644
--- a/samples/client/petstore/javascript-apollo/src/model/EnumTest.js
+++ b/samples/client/petstore/javascript-apollo/src/model/EnumTest.js
@@ -81,9 +81,35 @@ class EnumTest {
return obj;
}
+ /**
+ * Validates the JSON data with respect to EnumTest
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to EnumTest
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/File.js b/samples/client/petstore/javascript-apollo/src/model/File.js
index 12b51b87d89..5f5c9547a1f 100644
--- a/samples/client/petstore/javascript-apollo/src/model/File.js
+++ b/samples/client/petstore/javascript-apollo/src/model/File.js
@@ -55,9 +55,25 @@ class File {
return obj;
}
+ /**
+ * Validates the JSON data with respect to File
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to File
.
+ */
+ 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
diff --git a/samples/client/petstore/javascript-apollo/src/model/FileSchemaTestClass.js b/samples/client/petstore/javascript-apollo/src/model/FileSchemaTestClass.js
index b6fe9e90ece..8174d56245f 100644
--- a/samples/client/petstore/javascript-apollo/src/model/FileSchemaTestClass.js
+++ b/samples/client/petstore/javascript-apollo/src/model/FileSchemaTestClass.js
@@ -57,9 +57,35 @@ class FileSchemaTestClass {
return obj;
}
+ /**
+ * Validates the JSON data with respect to FileSchemaTestClass
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to FileSchemaTestClass
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Foo.js b/samples/client/petstore/javascript-apollo/src/model/Foo.js
index 3e4477b805b..3fc7819f99f 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Foo.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Foo.js
@@ -54,9 +54,25 @@ class Foo {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Foo
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Foo
.
+ */
+ 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'
diff --git a/samples/client/petstore/javascript-apollo/src/model/FooGetDefaultResponse.js b/samples/client/petstore/javascript-apollo/src/model/FooGetDefaultResponse.js
index ab3558a0415..b11d8859371 100644
--- a/samples/client/petstore/javascript-apollo/src/model/FooGetDefaultResponse.js
+++ b/samples/client/petstore/javascript-apollo/src/model/FooGetDefaultResponse.js
@@ -55,9 +55,25 @@ class FooGetDefaultResponse {
return obj;
}
+ /**
+ * Validates the JSON data with respect to FooGetDefaultResponse
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to FooGetDefaultResponse
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/FormatTest.js b/samples/client/petstore/javascript-apollo/src/model/FormatTest.js
index 00ee3533d06..65a34a7ff09 100644
--- a/samples/client/petstore/javascript-apollo/src/model/FormatTest.js
+++ b/samples/client/petstore/javascript-apollo/src/model/FormatTest.js
@@ -107,9 +107,47 @@ class FormatTest {
return obj;
}
+ /**
+ * Validates the JSON data with respect to FormatTest
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to FormatTest
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/HasOnlyReadOnly.js b/samples/client/petstore/javascript-apollo/src/model/HasOnlyReadOnly.js
index 57c9173723e..90943b87aef 100644
--- a/samples/client/petstore/javascript-apollo/src/model/HasOnlyReadOnly.js
+++ b/samples/client/petstore/javascript-apollo/src/model/HasOnlyReadOnly.js
@@ -57,9 +57,29 @@ class HasOnlyReadOnly {
return obj;
}
+ /**
+ * Validates the JSON data with respect to HasOnlyReadOnly
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to HasOnlyReadOnly
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/HealthCheckResult.js b/samples/client/petstore/javascript-apollo/src/model/HealthCheckResult.js
index 2dd62c2a267..112fd778426 100644
--- a/samples/client/petstore/javascript-apollo/src/model/HealthCheckResult.js
+++ b/samples/client/petstore/javascript-apollo/src/model/HealthCheckResult.js
@@ -55,9 +55,25 @@ class HealthCheckResult {
return obj;
}
+ /**
+ * Validates the JSON data with respect to HealthCheckResult
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to HealthCheckResult
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/List.js b/samples/client/petstore/javascript-apollo/src/model/List.js
index 18d6a258491..ca916761c0f 100644
--- a/samples/client/petstore/javascript-apollo/src/model/List.js
+++ b/samples/client/petstore/javascript-apollo/src/model/List.js
@@ -54,9 +54,25 @@ class List {
return obj;
}
+ /**
+ * Validates the JSON data with respect to List
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to List
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/MapTest.js b/samples/client/petstore/javascript-apollo/src/model/MapTest.js
index 3113ad56bd4..478e2347fa7 100644
--- a/samples/client/petstore/javascript-apollo/src/model/MapTest.js
+++ b/samples/client/petstore/javascript-apollo/src/model/MapTest.js
@@ -63,9 +63,21 @@ class MapTest {
return obj;
}
+ /**
+ * Validates the JSON data with respect to MapTest
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to MapTest
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Object.>} map_map_of_string
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/MixedPropertiesAndAdditionalPropertiesClass.js b/samples/client/petstore/javascript-apollo/src/model/MixedPropertiesAndAdditionalPropertiesClass.js
index 7cd9ca844f9..8131fa36203 100644
--- a/samples/client/petstore/javascript-apollo/src/model/MixedPropertiesAndAdditionalPropertiesClass.js
+++ b/samples/client/petstore/javascript-apollo/src/model/MixedPropertiesAndAdditionalPropertiesClass.js
@@ -61,9 +61,25 @@ class MixedPropertiesAndAdditionalPropertiesClass {
return obj;
}
+ /**
+ * Validates the JSON data with respect to MixedPropertiesAndAdditionalPropertiesClass
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to MixedPropertiesAndAdditionalPropertiesClass
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Model200Response.js b/samples/client/petstore/javascript-apollo/src/model/Model200Response.js
index 88daaba2ebb..604683735fc 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Model200Response.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Model200Response.js
@@ -58,9 +58,25 @@ class Model200Response {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Model200Response
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Model200Response
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Name.js b/samples/client/petstore/javascript-apollo/src/model/Name.js
index 740d4bad15b..978fbaa7efe 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Name.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Name.js
@@ -66,9 +66,31 @@ class Name {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Name
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Name
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/NestedColor.js b/samples/client/petstore/javascript-apollo/src/model/NestedColor.js
new file mode 100644
index 00000000000..5b611469036
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/src/model/NestedColor.js
@@ -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 NestedColor
.
+ * @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 NestedColor
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 NestedColor
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 NestedColor
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to NestedColor
.
+ */
+ 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;
+
diff --git a/samples/client/petstore/javascript-apollo/src/model/NestedOneOf.js b/samples/client/petstore/javascript-apollo/src/model/NestedOneOf.js
new file mode 100644
index 00000000000..3ea6ed798b7
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/src/model/NestedOneOf.js
@@ -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 NestedOneOf
.
+ * @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 NestedOneOf
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 NestedOneOf
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 NestedOneOf
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to NestedOneOf
.
+ */
+ 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;
+
diff --git a/samples/client/petstore/javascript-apollo/src/model/NullableClass.js b/samples/client/petstore/javascript-apollo/src/model/NullableClass.js
index 12a0f2509b6..33dd77a1820 100644
--- a/samples/client/petstore/javascript-apollo/src/model/NullableClass.js
+++ b/samples/client/petstore/javascript-apollo/src/model/NullableClass.js
@@ -91,9 +91,37 @@ class NullableClass {
return obj;
}
+ /**
+ * Validates the JSON data with respect to NullableClass
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to NullableClass
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/NumberOnly.js b/samples/client/petstore/javascript-apollo/src/model/NumberOnly.js
index 449e08bd9a9..deb4f2961f6 100644
--- a/samples/client/petstore/javascript-apollo/src/model/NumberOnly.js
+++ b/samples/client/petstore/javascript-apollo/src/model/NumberOnly.js
@@ -54,9 +54,21 @@ class NumberOnly {
return obj;
}
+ /**
+ * Validates the JSON data with respect to NumberOnly
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to NumberOnly
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Number} JustNumber
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/ObjectWithDeprecatedFields.js b/samples/client/petstore/javascript-apollo/src/model/ObjectWithDeprecatedFields.js
index a3d0d400943..29e80fd2664 100644
--- a/samples/client/petstore/javascript-apollo/src/model/ObjectWithDeprecatedFields.js
+++ b/samples/client/petstore/javascript-apollo/src/model/ObjectWithDeprecatedFields.js
@@ -64,9 +64,33 @@ class ObjectWithDeprecatedFields {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ObjectWithDeprecatedFields
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ObjectWithDeprecatedFields
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Order.js b/samples/client/petstore/javascript-apollo/src/model/Order.js
index 1d28748e822..ad586f185d4 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Order.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Order.js
@@ -69,9 +69,25 @@ class Order {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Order
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Order
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/OuterComposite.js b/samples/client/petstore/javascript-apollo/src/model/OuterComposite.js
index cc4ed6c172d..1c6a3c9a857 100644
--- a/samples/client/petstore/javascript-apollo/src/model/OuterComposite.js
+++ b/samples/client/petstore/javascript-apollo/src/model/OuterComposite.js
@@ -60,9 +60,25 @@ class OuterComposite {
return obj;
}
+ /**
+ * Validates the JSON data with respect to OuterComposite
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to OuterComposite
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/OuterObjectWithEnumProperty.js b/samples/client/petstore/javascript-apollo/src/model/OuterObjectWithEnumProperty.js
index d2ef0e04371..b9ead482af5 100644
--- a/samples/client/petstore/javascript-apollo/src/model/OuterObjectWithEnumProperty.js
+++ b/samples/client/petstore/javascript-apollo/src/model/OuterObjectWithEnumProperty.js
@@ -57,9 +57,27 @@ class OuterObjectWithEnumProperty {
return obj;
}
+ /**
+ * Validates the JSON data with respect to OuterObjectWithEnumProperty
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to OuterObjectWithEnumProperty
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Pet.js b/samples/client/petstore/javascript-apollo/src/model/Pet.js
index b88e5d869f6..cc5239c6a17 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Pet.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Pet.js
@@ -75,9 +75,53 @@ class Pet {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Pet
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Pet
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Pig.js b/samples/client/petstore/javascript-apollo/src/model/Pig.js
new file mode 100644
index 00000000000..45f822e0276
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/src/model/Pig.js
@@ -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 Pig
.
+ * @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 Pig
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 Pig
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 BasquePig
, DanishPig
.
+ * @return {(module:model/BasquePig|module:model/DanishPig)} The actual instance.
+ */
+ getActualInstance() {
+ return this.actualInstance;
+ }
+
+ /**
+ * Sets the actaul instance, which can be BasquePig
, DanishPig
.
+ * @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;
+
diff --git a/samples/client/petstore/javascript-apollo/src/model/ReadOnlyFirst.js b/samples/client/petstore/javascript-apollo/src/model/ReadOnlyFirst.js
index 8e2a39cf2ae..b0fa7628f16 100644
--- a/samples/client/petstore/javascript-apollo/src/model/ReadOnlyFirst.js
+++ b/samples/client/petstore/javascript-apollo/src/model/ReadOnlyFirst.js
@@ -57,9 +57,29 @@ class ReadOnlyFirst {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ReadOnlyFirst
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ReadOnlyFirst
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Return.js b/samples/client/petstore/javascript-apollo/src/model/Return.js
index 304ebb46f04..616574b5fc3 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Return.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Return.js
@@ -55,9 +55,21 @@ class Return {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Return
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Return
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Number} return
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/SpecialModelName.js b/samples/client/petstore/javascript-apollo/src/model/SpecialModelName.js
index 45ba7d7ea09..b9ece722920 100644
--- a/samples/client/petstore/javascript-apollo/src/model/SpecialModelName.js
+++ b/samples/client/petstore/javascript-apollo/src/model/SpecialModelName.js
@@ -54,9 +54,21 @@ class SpecialModelName {
return obj;
}
+ /**
+ * Validates the JSON data with respect to SpecialModelName
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to SpecialModelName
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Number} $special[property.name]
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/Tag.js b/samples/client/petstore/javascript-apollo/src/model/Tag.js
index 3330530c0c2..c24706b827e 100644
--- a/samples/client/petstore/javascript-apollo/src/model/Tag.js
+++ b/samples/client/petstore/javascript-apollo/src/model/Tag.js
@@ -57,9 +57,25 @@ class Tag {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Tag
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Tag
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/src/model/User.js b/samples/client/petstore/javascript-apollo/src/model/User.js
index 473bf7c78bc..145851f479b 100644
--- a/samples/client/petstore/javascript-apollo/src/model/User.js
+++ b/samples/client/petstore/javascript-apollo/src/model/User.js
@@ -75,9 +75,45 @@ class User {
return obj;
}
+ /**
+ * Validates the JSON data with respect to User
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to User
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-apollo/test/model/BasquePig.spec.js b/samples/client/petstore/javascript-apollo/test/model/BasquePig.spec.js
new file mode 100644
index 00000000000..da5196fc092
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/test/model/BasquePig.spec.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.BasquePig();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('BasquePig', function() {
+ it('should create an instance of BasquePig', function() {
+ // uncomment below and update the code to test BasquePig
+ //var instance = new OpenApiPetstore.BasquePig();
+ //expect(instance).to.be.a(OpenApiPetstore.BasquePig);
+ });
+
+ it('should have the property className (base name: "className")', function() {
+ // uncomment below and update the code to test the property className
+ //var instance = new OpenApiPetstore.BasquePig();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property color (base name: "color")', function() {
+ // uncomment below and update the code to test the property color
+ //var instance = new OpenApiPetstore.BasquePig();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-apollo/test/model/Color.spec.js b/samples/client/petstore/javascript-apollo/test/model/Color.spec.js
new file mode 100644
index 00000000000..c079e6e5111
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/test/model/Color.spec.js
@@ -0,0 +1,59 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.Color();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('Color', function() {
+ it('should create an instance of Color', function() {
+ // uncomment below and update the code to test Color
+ //var instance = new OpenApiPetstore.Color();
+ //expect(instance).to.be.a(OpenApiPetstore.Color);
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-apollo/test/model/DanishPig.spec.js b/samples/client/petstore/javascript-apollo/test/model/DanishPig.spec.js
new file mode 100644
index 00000000000..f2272918461
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/test/model/DanishPig.spec.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.DanishPig();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('DanishPig', function() {
+ it('should create an instance of DanishPig', function() {
+ // uncomment below and update the code to test DanishPig
+ //var instance = new OpenApiPetstore.DanishPig();
+ //expect(instance).to.be.a(OpenApiPetstore.DanishPig);
+ });
+
+ it('should have the property className (base name: "className")', function() {
+ // uncomment below and update the code to test the property className
+ //var instance = new OpenApiPetstore.DanishPig();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property size (base name: "size")', function() {
+ // uncomment below and update the code to test the property size
+ //var instance = new OpenApiPetstore.DanishPig();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-apollo/test/model/NestedColor.spec.js b/samples/client/petstore/javascript-apollo/test/model/NestedColor.spec.js
new file mode 100644
index 00000000000..00a5813236d
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/test/model/NestedColor.spec.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.NestedColor();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('NestedColor', function() {
+ it('should create an instance of NestedColor', function() {
+ // uncomment below and update the code to test NestedColor
+ //var instance = new OpenApiPetstore.NestedColor();
+ //expect(instance).to.be.a(OpenApiPetstore.NestedColor);
+ });
+
+ it('should have the property size (base name: "size")', function() {
+ // uncomment below and update the code to test the property size
+ //var instance = new OpenApiPetstore.NestedColor();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property nested (base name: "nested")', function() {
+ // uncomment below and update the code to test the property nested
+ //var instance = new OpenApiPetstore.NestedColor();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-apollo/test/model/NestedOneOf.spec.js b/samples/client/petstore/javascript-apollo/test/model/NestedOneOf.spec.js
new file mode 100644
index 00000000000..5a54e7fbb08
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/test/model/NestedOneOf.spec.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.NestedOneOf();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('NestedOneOf', function() {
+ it('should create an instance of NestedOneOf', function() {
+ // uncomment below and update the code to test NestedOneOf
+ //var instance = new OpenApiPetstore.NestedOneOf();
+ //expect(instance).to.be.a(OpenApiPetstore.NestedOneOf);
+ });
+
+ it('should have the property size (base name: "size")', function() {
+ // uncomment below and update the code to test the property size
+ //var instance = new OpenApiPetstore.NestedOneOf();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property nestedPig (base name: "nested_pig")', function() {
+ // uncomment below and update the code to test the property nestedPig
+ //var instance = new OpenApiPetstore.NestedOneOf();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-apollo/test/model/Pig.spec.js b/samples/client/petstore/javascript-apollo/test/model/Pig.spec.js
new file mode 100644
index 00000000000..994a590578e
--- /dev/null
+++ b/samples/client/petstore/javascript-apollo/test/model/Pig.spec.js
@@ -0,0 +1,77 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.Pig();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('Pig', function() {
+ it('should create an instance of Pig', function() {
+ // uncomment below and update the code to test Pig
+ //var instance = new OpenApiPetstore.Pig();
+ //expect(instance).to.be.a(OpenApiPetstore.Pig);
+ });
+
+ it('should have the property className (base name: "className")', function() {
+ // uncomment below and update the code to test the property className
+ //var instance = new OpenApiPetstore.Pig();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property color (base name: "color")', function() {
+ // uncomment below and update the code to test the property color
+ //var instance = new OpenApiPetstore.Pig();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property size (base name: "size")', function() {
+ // uncomment below and update the code to test the property size
+ //var instance = new OpenApiPetstore.Pig();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-es6/.openapi-generator/FILES b/samples/client/petstore/javascript-es6/.openapi-generator/FILES
index 0440bb2716c..f83260318a5 100644
--- a/samples/client/petstore/javascript-es6/.openapi-generator/FILES
+++ b/samples/client/petstore/javascript-es6/.openapi-generator/FILES
@@ -9,12 +9,15 @@ docs/ApiResponse.md
docs/ArrayOfArrayOfNumberOnly.md
docs/ArrayOfNumberOnly.md
docs/ArrayTest.md
+docs/BasquePig.md
docs/Capitalization.md
docs/Cat.md
docs/CatAllOf.md
docs/Category.md
docs/ClassModel.md
docs/Client.md
+docs/Color.md
+docs/DanishPig.md
docs/DefaultApi.md
docs/DeprecatedObject.md
docs/Dog.md
@@ -36,6 +39,8 @@ docs/MapTest.md
docs/MixedPropertiesAndAdditionalPropertiesClass.md
docs/Model200Response.md
docs/Name.md
+docs/NestedColor.md
+docs/NestedOneOf.md
docs/NullableClass.md
docs/NumberOnly.md
docs/ObjectWithDeprecatedFields.md
@@ -48,6 +53,7 @@ docs/OuterEnumIntegerDefaultValue.md
docs/OuterObjectWithEnumProperty.md
docs/Pet.md
docs/PetApi.md
+docs/Pig.md
docs/ReadOnlyFirst.md
docs/Return.md
docs/SpecialModelName.md
@@ -73,12 +79,15 @@ src/model/ApiResponse.js
src/model/ArrayOfArrayOfNumberOnly.js
src/model/ArrayOfNumberOnly.js
src/model/ArrayTest.js
+src/model/BasquePig.js
src/model/Capitalization.js
src/model/Cat.js
src/model/CatAllOf.js
src/model/Category.js
src/model/ClassModel.js
src/model/Client.js
+src/model/Color.js
+src/model/DanishPig.js
src/model/DeprecatedObject.js
src/model/Dog.js
src/model/DogAllOf.js
@@ -97,6 +106,8 @@ src/model/MapTest.js
src/model/MixedPropertiesAndAdditionalPropertiesClass.js
src/model/Model200Response.js
src/model/Name.js
+src/model/NestedColor.js
+src/model/NestedOneOf.js
src/model/NullableClass.js
src/model/NumberOnly.js
src/model/ObjectWithDeprecatedFields.js
@@ -108,6 +119,7 @@ src/model/OuterEnumInteger.js
src/model/OuterEnumIntegerDefaultValue.js
src/model/OuterObjectWithEnumProperty.js
src/model/Pet.js
+src/model/Pig.js
src/model/ReadOnlyFirst.js
src/model/Return.js
src/model/SpecialModelName.js
diff --git a/samples/client/petstore/javascript-es6/README.md b/samples/client/petstore/javascript-es6/README.md
index 2f7325ceebb..a6a90be126d 100644
--- a/samples/client/petstore/javascript-es6/README.md
+++ b/samples/client/petstore/javascript-es6/README.md
@@ -171,12 +171,15 @@ Class | Method | HTTP request | Description
- [OpenApiPetstore.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
- [OpenApiPetstore.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [OpenApiPetstore.ArrayTest](docs/ArrayTest.md)
+ - [OpenApiPetstore.BasquePig](docs/BasquePig.md)
- [OpenApiPetstore.Capitalization](docs/Capitalization.md)
- [OpenApiPetstore.Cat](docs/Cat.md)
- [OpenApiPetstore.CatAllOf](docs/CatAllOf.md)
- [OpenApiPetstore.Category](docs/Category.md)
- [OpenApiPetstore.ClassModel](docs/ClassModel.md)
- [OpenApiPetstore.Client](docs/Client.md)
+ - [OpenApiPetstore.Color](docs/Color.md)
+ - [OpenApiPetstore.DanishPig](docs/DanishPig.md)
- [OpenApiPetstore.DeprecatedObject](docs/DeprecatedObject.md)
- [OpenApiPetstore.Dog](docs/Dog.md)
- [OpenApiPetstore.DogAllOf](docs/DogAllOf.md)
@@ -195,6 +198,8 @@ Class | Method | HTTP request | Description
- [OpenApiPetstore.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
- [OpenApiPetstore.Model200Response](docs/Model200Response.md)
- [OpenApiPetstore.Name](docs/Name.md)
+ - [OpenApiPetstore.NestedColor](docs/NestedColor.md)
+ - [OpenApiPetstore.NestedOneOf](docs/NestedOneOf.md)
- [OpenApiPetstore.NullableClass](docs/NullableClass.md)
- [OpenApiPetstore.NumberOnly](docs/NumberOnly.md)
- [OpenApiPetstore.ObjectWithDeprecatedFields](docs/ObjectWithDeprecatedFields.md)
@@ -206,6 +211,7 @@ Class | Method | HTTP request | Description
- [OpenApiPetstore.OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md)
- [OpenApiPetstore.OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md)
- [OpenApiPetstore.Pet](docs/Pet.md)
+ - [OpenApiPetstore.Pig](docs/Pig.md)
- [OpenApiPetstore.ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [OpenApiPetstore.Return](docs/Return.md)
- [OpenApiPetstore.SpecialModelName](docs/SpecialModelName.md)
diff --git a/samples/client/petstore/javascript-es6/docs/BasquePig.md b/samples/client/petstore/javascript-es6/docs/BasquePig.md
new file mode 100644
index 00000000000..77d1e74bc71
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/docs/BasquePig.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.BasquePig
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**className** | **String** | |
+**color** | **String** | |
+
+
diff --git a/samples/client/petstore/javascript-es6/docs/Color.md b/samples/client/petstore/javascript-es6/docs/Color.md
new file mode 100644
index 00000000000..5f0e6f0dfba
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/docs/Color.md
@@ -0,0 +1,8 @@
+# OpenApiPetstore.Color
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+
diff --git a/samples/client/petstore/javascript-es6/docs/DanishPig.md b/samples/client/petstore/javascript-es6/docs/DanishPig.md
new file mode 100644
index 00000000000..7de3e60db36
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/docs/DanishPig.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.DanishPig
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**className** | **String** | |
+**size** | **Number** | |
+
+
diff --git a/samples/client/petstore/javascript-es6/docs/NestedColor.md b/samples/client/petstore/javascript-es6/docs/NestedColor.md
new file mode 100644
index 00000000000..aea6b444942
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/docs/NestedColor.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.NestedColor
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**size** | **Number** | | [optional]
+**nested** | [**Color**](Color.md) | | [optional]
+
+
diff --git a/samples/client/petstore/javascript-es6/docs/NestedOneOf.md b/samples/client/petstore/javascript-es6/docs/NestedOneOf.md
new file mode 100644
index 00000000000..b5228e89c70
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/docs/NestedOneOf.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.NestedOneOf
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**size** | **Number** | | [optional]
+**nestedPig** | [**Pig**](Pig.md) | | [optional]
+
+
diff --git a/samples/client/petstore/javascript-es6/docs/Pig.md b/samples/client/petstore/javascript-es6/docs/Pig.md
new file mode 100644
index 00000000000..a94e1687cc5
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/docs/Pig.md
@@ -0,0 +1,11 @@
+# OpenApiPetstore.Pig
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**className** | **String** | |
+**color** | **String** | |
+**size** | **Number** | |
+
+
diff --git a/samples/client/petstore/javascript-es6/src/index.js b/samples/client/petstore/javascript-es6/src/index.js
index 474899d9c51..a95a17ec1b0 100644
--- a/samples/client/petstore/javascript-es6/src/index.js
+++ b/samples/client/petstore/javascript-es6/src/index.js
@@ -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}
diff --git a/samples/client/petstore/javascript-es6/src/model/AdditionalPropertiesClass.js b/samples/client/petstore/javascript-es6/src/model/AdditionalPropertiesClass.js
index d6d83cca284..3849c00c595 100644
--- a/samples/client/petstore/javascript-es6/src/model/AdditionalPropertiesClass.js
+++ b/samples/client/petstore/javascript-es6/src/model/AdditionalPropertiesClass.js
@@ -57,9 +57,21 @@ class AdditionalPropertiesClass {
return obj;
}
+ /**
+ * Validates the JSON data with respect to AdditionalPropertiesClass
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to AdditionalPropertiesClass
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Object.} map_property
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Animal.js b/samples/client/petstore/javascript-es6/src/model/Animal.js
index 7cb9017160b..27c6975b599 100644
--- a/samples/client/petstore/javascript-es6/src/model/Animal.js
+++ b/samples/client/petstore/javascript-es6/src/model/Animal.js
@@ -59,9 +59,35 @@ class Animal {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Animal
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Animal
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/ApiResponse.js b/samples/client/petstore/javascript-es6/src/model/ApiResponse.js
index f5af17fdf82..6db561122f1 100644
--- a/samples/client/petstore/javascript-es6/src/model/ApiResponse.js
+++ b/samples/client/petstore/javascript-es6/src/model/ApiResponse.js
@@ -60,9 +60,29 @@ class ApiResponse {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ApiResponse
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ApiResponse
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/ArrayOfArrayOfNumberOnly.js b/samples/client/petstore/javascript-es6/src/model/ArrayOfArrayOfNumberOnly.js
index eadd7db414b..461c6b5b35b 100644
--- a/samples/client/petstore/javascript-es6/src/model/ArrayOfArrayOfNumberOnly.js
+++ b/samples/client/petstore/javascript-es6/src/model/ArrayOfArrayOfNumberOnly.js
@@ -54,9 +54,25 @@ class ArrayOfArrayOfNumberOnly {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ArrayOfArrayOfNumberOnly
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ArrayOfArrayOfNumberOnly
.
+ */
+ 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.>} ArrayArrayNumber
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/ArrayOfNumberOnly.js b/samples/client/petstore/javascript-es6/src/model/ArrayOfNumberOnly.js
index 1145a62630d..4c2513c1076 100644
--- a/samples/client/petstore/javascript-es6/src/model/ArrayOfNumberOnly.js
+++ b/samples/client/petstore/javascript-es6/src/model/ArrayOfNumberOnly.js
@@ -54,9 +54,25 @@ class ArrayOfNumberOnly {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ArrayOfNumberOnly
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ArrayOfNumberOnly
.
+ */
+ 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.} ArrayNumber
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/ArrayTest.js b/samples/client/petstore/javascript-es6/src/model/ArrayTest.js
index 18bc925308a..3fc3c9b7f92 100644
--- a/samples/client/petstore/javascript-es6/src/model/ArrayTest.js
+++ b/samples/client/petstore/javascript-es6/src/model/ArrayTest.js
@@ -61,9 +61,33 @@ class ArrayTest {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ArrayTest
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ArrayTest
.
+ */
+ 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.} array_of_string
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/BasquePig.js b/samples/client/petstore/javascript-es6/src/model/BasquePig.js
new file mode 100644
index 00000000000..dc26c47c4fb
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/src/model/BasquePig.js
@@ -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 BasquePig
.
+ * @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 BasquePig
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 BasquePig
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 BasquePig
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to BasquePig
.
+ */
+ 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;
+
diff --git a/samples/client/petstore/javascript-es6/src/model/Capitalization.js b/samples/client/petstore/javascript-es6/src/model/Capitalization.js
index 63b14361fee..cf4ef4348ac 100644
--- a/samples/client/petstore/javascript-es6/src/model/Capitalization.js
+++ b/samples/client/petstore/javascript-es6/src/model/Capitalization.js
@@ -69,9 +69,45 @@ class Capitalization {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Capitalization
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Capitalization
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Cat.js b/samples/client/petstore/javascript-es6/src/model/Cat.js
index d18ce94e70e..203a652cfc4 100644
--- a/samples/client/petstore/javascript-es6/src/model/Cat.js
+++ b/samples/client/petstore/javascript-es6/src/model/Cat.js
@@ -63,9 +63,27 @@ class Cat {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Cat
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Cat
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/CatAllOf.js b/samples/client/petstore/javascript-es6/src/model/CatAllOf.js
index c71ea7129b0..8c0d5bfbbd4 100644
--- a/samples/client/petstore/javascript-es6/src/model/CatAllOf.js
+++ b/samples/client/petstore/javascript-es6/src/model/CatAllOf.js
@@ -54,9 +54,21 @@ class CatAllOf {
return obj;
}
+ /**
+ * Validates the JSON data with respect to CatAllOf
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to CatAllOf
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Boolean} declawed
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Category.js b/samples/client/petstore/javascript-es6/src/model/Category.js
index 557e8e18620..fc304998f40 100644
--- a/samples/client/petstore/javascript-es6/src/model/Category.js
+++ b/samples/client/petstore/javascript-es6/src/model/Category.js
@@ -59,9 +59,31 @@ class Category {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Category
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Category
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/ClassModel.js b/samples/client/petstore/javascript-es6/src/model/ClassModel.js
index ee1f1417777..ba614443ebf 100644
--- a/samples/client/petstore/javascript-es6/src/model/ClassModel.js
+++ b/samples/client/petstore/javascript-es6/src/model/ClassModel.js
@@ -55,9 +55,25 @@ class ClassModel {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ClassModel
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ClassModel
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Client.js b/samples/client/petstore/javascript-es6/src/model/Client.js
index 8521c85043b..4089ff37ee6 100644
--- a/samples/client/petstore/javascript-es6/src/model/Client.js
+++ b/samples/client/petstore/javascript-es6/src/model/Client.js
@@ -54,9 +54,25 @@ class Client {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Client
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Client
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Color.js b/samples/client/petstore/javascript-es6/src/model/Color.js
new file mode 100644
index 00000000000..759e5df97af
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/src/model/Color.js
@@ -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 Color
.
+ * 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 Color
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 Color
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 String
, [Number]
.
+ * @return {(module:model/String|module:model/[Number])} The actual instance.
+ */
+ getActualInstance() {
+ return this.actualInstance;
+ }
+
+ /**
+ * Sets the actaul instance, which can be String
, [Number]
.
+ * @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;
+
diff --git a/samples/client/petstore/javascript-es6/src/model/DanishPig.js b/samples/client/petstore/javascript-es6/src/model/DanishPig.js
new file mode 100644
index 00000000000..4023e9d637f
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/src/model/DanishPig.js
@@ -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 DanishPig
.
+ * @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 DanishPig
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 DanishPig
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 DanishPig
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to DanishPig
.
+ */
+ 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;
+
diff --git a/samples/client/petstore/javascript-es6/src/model/DeprecatedObject.js b/samples/client/petstore/javascript-es6/src/model/DeprecatedObject.js
index c3298d50200..d7c874345f1 100644
--- a/samples/client/petstore/javascript-es6/src/model/DeprecatedObject.js
+++ b/samples/client/petstore/javascript-es6/src/model/DeprecatedObject.js
@@ -54,9 +54,25 @@ class DeprecatedObject {
return obj;
}
+ /**
+ * Validates the JSON data with respect to DeprecatedObject
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to DeprecatedObject
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Dog.js b/samples/client/petstore/javascript-es6/src/model/Dog.js
index b101feecd32..dd3f1ebb509 100644
--- a/samples/client/petstore/javascript-es6/src/model/Dog.js
+++ b/samples/client/petstore/javascript-es6/src/model/Dog.js
@@ -63,9 +63,31 @@ class Dog {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Dog
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Dog
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/DogAllOf.js b/samples/client/petstore/javascript-es6/src/model/DogAllOf.js
index 58ecede6126..beb42db2ec8 100644
--- a/samples/client/petstore/javascript-es6/src/model/DogAllOf.js
+++ b/samples/client/petstore/javascript-es6/src/model/DogAllOf.js
@@ -54,9 +54,25 @@ class DogAllOf {
return obj;
}
+ /**
+ * Validates the JSON data with respect to DogAllOf
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to DogAllOf
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/EnumArrays.js b/samples/client/petstore/javascript-es6/src/model/EnumArrays.js
index 7fe64e3111a..2289689e349 100644
--- a/samples/client/petstore/javascript-es6/src/model/EnumArrays.js
+++ b/samples/client/petstore/javascript-es6/src/model/EnumArrays.js
@@ -57,9 +57,29 @@ class EnumArrays {
return obj;
}
+ /**
+ * Validates the JSON data with respect to EnumArrays
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to EnumArrays
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/EnumTest.js b/samples/client/petstore/javascript-es6/src/model/EnumTest.js
index dc684b7c26b..b1556a0613f 100644
--- a/samples/client/petstore/javascript-es6/src/model/EnumTest.js
+++ b/samples/client/petstore/javascript-es6/src/model/EnumTest.js
@@ -81,9 +81,35 @@ class EnumTest {
return obj;
}
+ /**
+ * Validates the JSON data with respect to EnumTest
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to EnumTest
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/File.js b/samples/client/petstore/javascript-es6/src/model/File.js
index 12b51b87d89..5f5c9547a1f 100644
--- a/samples/client/petstore/javascript-es6/src/model/File.js
+++ b/samples/client/petstore/javascript-es6/src/model/File.js
@@ -55,9 +55,25 @@ class File {
return obj;
}
+ /**
+ * Validates the JSON data with respect to File
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to File
.
+ */
+ 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
diff --git a/samples/client/petstore/javascript-es6/src/model/FileSchemaTestClass.js b/samples/client/petstore/javascript-es6/src/model/FileSchemaTestClass.js
index b6fe9e90ece..8174d56245f 100644
--- a/samples/client/petstore/javascript-es6/src/model/FileSchemaTestClass.js
+++ b/samples/client/petstore/javascript-es6/src/model/FileSchemaTestClass.js
@@ -57,9 +57,35 @@ class FileSchemaTestClass {
return obj;
}
+ /**
+ * Validates the JSON data with respect to FileSchemaTestClass
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to FileSchemaTestClass
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Foo.js b/samples/client/petstore/javascript-es6/src/model/Foo.js
index 3e4477b805b..3fc7819f99f 100644
--- a/samples/client/petstore/javascript-es6/src/model/Foo.js
+++ b/samples/client/petstore/javascript-es6/src/model/Foo.js
@@ -54,9 +54,25 @@ class Foo {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Foo
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Foo
.
+ */
+ 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'
diff --git a/samples/client/petstore/javascript-es6/src/model/FooGetDefaultResponse.js b/samples/client/petstore/javascript-es6/src/model/FooGetDefaultResponse.js
index ab3558a0415..b11d8859371 100644
--- a/samples/client/petstore/javascript-es6/src/model/FooGetDefaultResponse.js
+++ b/samples/client/petstore/javascript-es6/src/model/FooGetDefaultResponse.js
@@ -55,9 +55,25 @@ class FooGetDefaultResponse {
return obj;
}
+ /**
+ * Validates the JSON data with respect to FooGetDefaultResponse
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to FooGetDefaultResponse
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/FormatTest.js b/samples/client/petstore/javascript-es6/src/model/FormatTest.js
index 00ee3533d06..65a34a7ff09 100644
--- a/samples/client/petstore/javascript-es6/src/model/FormatTest.js
+++ b/samples/client/petstore/javascript-es6/src/model/FormatTest.js
@@ -107,9 +107,47 @@ class FormatTest {
return obj;
}
+ /**
+ * Validates the JSON data with respect to FormatTest
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to FormatTest
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/HasOnlyReadOnly.js b/samples/client/petstore/javascript-es6/src/model/HasOnlyReadOnly.js
index 57c9173723e..90943b87aef 100644
--- a/samples/client/petstore/javascript-es6/src/model/HasOnlyReadOnly.js
+++ b/samples/client/petstore/javascript-es6/src/model/HasOnlyReadOnly.js
@@ -57,9 +57,29 @@ class HasOnlyReadOnly {
return obj;
}
+ /**
+ * Validates the JSON data with respect to HasOnlyReadOnly
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to HasOnlyReadOnly
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/HealthCheckResult.js b/samples/client/petstore/javascript-es6/src/model/HealthCheckResult.js
index 2dd62c2a267..112fd778426 100644
--- a/samples/client/petstore/javascript-es6/src/model/HealthCheckResult.js
+++ b/samples/client/petstore/javascript-es6/src/model/HealthCheckResult.js
@@ -55,9 +55,25 @@ class HealthCheckResult {
return obj;
}
+ /**
+ * Validates the JSON data with respect to HealthCheckResult
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to HealthCheckResult
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/List.js b/samples/client/petstore/javascript-es6/src/model/List.js
index 18d6a258491..ca916761c0f 100644
--- a/samples/client/petstore/javascript-es6/src/model/List.js
+++ b/samples/client/petstore/javascript-es6/src/model/List.js
@@ -54,9 +54,25 @@ class List {
return obj;
}
+ /**
+ * Validates the JSON data with respect to List
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to List
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/MapTest.js b/samples/client/petstore/javascript-es6/src/model/MapTest.js
index 3113ad56bd4..478e2347fa7 100644
--- a/samples/client/petstore/javascript-es6/src/model/MapTest.js
+++ b/samples/client/petstore/javascript-es6/src/model/MapTest.js
@@ -63,9 +63,21 @@ class MapTest {
return obj;
}
+ /**
+ * Validates the JSON data with respect to MapTest
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to MapTest
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Object.>} map_map_of_string
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/MixedPropertiesAndAdditionalPropertiesClass.js b/samples/client/petstore/javascript-es6/src/model/MixedPropertiesAndAdditionalPropertiesClass.js
index 7cd9ca844f9..8131fa36203 100644
--- a/samples/client/petstore/javascript-es6/src/model/MixedPropertiesAndAdditionalPropertiesClass.js
+++ b/samples/client/petstore/javascript-es6/src/model/MixedPropertiesAndAdditionalPropertiesClass.js
@@ -61,9 +61,25 @@ class MixedPropertiesAndAdditionalPropertiesClass {
return obj;
}
+ /**
+ * Validates the JSON data with respect to MixedPropertiesAndAdditionalPropertiesClass
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to MixedPropertiesAndAdditionalPropertiesClass
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Model200Response.js b/samples/client/petstore/javascript-es6/src/model/Model200Response.js
index 88daaba2ebb..604683735fc 100644
--- a/samples/client/petstore/javascript-es6/src/model/Model200Response.js
+++ b/samples/client/petstore/javascript-es6/src/model/Model200Response.js
@@ -58,9 +58,25 @@ class Model200Response {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Model200Response
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Model200Response
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Name.js b/samples/client/petstore/javascript-es6/src/model/Name.js
index 740d4bad15b..978fbaa7efe 100644
--- a/samples/client/petstore/javascript-es6/src/model/Name.js
+++ b/samples/client/petstore/javascript-es6/src/model/Name.js
@@ -66,9 +66,31 @@ class Name {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Name
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Name
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/NestedColor.js b/samples/client/petstore/javascript-es6/src/model/NestedColor.js
new file mode 100644
index 00000000000..5b611469036
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/src/model/NestedColor.js
@@ -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 NestedColor
.
+ * @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 NestedColor
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 NestedColor
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 NestedColor
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to NestedColor
.
+ */
+ 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;
+
diff --git a/samples/client/petstore/javascript-es6/src/model/NestedOneOf.js b/samples/client/petstore/javascript-es6/src/model/NestedOneOf.js
new file mode 100644
index 00000000000..3ea6ed798b7
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/src/model/NestedOneOf.js
@@ -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 NestedOneOf
.
+ * @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 NestedOneOf
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 NestedOneOf
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 NestedOneOf
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to NestedOneOf
.
+ */
+ 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;
+
diff --git a/samples/client/petstore/javascript-es6/src/model/NullableClass.js b/samples/client/petstore/javascript-es6/src/model/NullableClass.js
index 12a0f2509b6..33dd77a1820 100644
--- a/samples/client/petstore/javascript-es6/src/model/NullableClass.js
+++ b/samples/client/petstore/javascript-es6/src/model/NullableClass.js
@@ -91,9 +91,37 @@ class NullableClass {
return obj;
}
+ /**
+ * Validates the JSON data with respect to NullableClass
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to NullableClass
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/NumberOnly.js b/samples/client/petstore/javascript-es6/src/model/NumberOnly.js
index 449e08bd9a9..deb4f2961f6 100644
--- a/samples/client/petstore/javascript-es6/src/model/NumberOnly.js
+++ b/samples/client/petstore/javascript-es6/src/model/NumberOnly.js
@@ -54,9 +54,21 @@ class NumberOnly {
return obj;
}
+ /**
+ * Validates the JSON data with respect to NumberOnly
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to NumberOnly
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Number} JustNumber
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/ObjectWithDeprecatedFields.js b/samples/client/petstore/javascript-es6/src/model/ObjectWithDeprecatedFields.js
index a3d0d400943..29e80fd2664 100644
--- a/samples/client/petstore/javascript-es6/src/model/ObjectWithDeprecatedFields.js
+++ b/samples/client/petstore/javascript-es6/src/model/ObjectWithDeprecatedFields.js
@@ -64,9 +64,33 @@ class ObjectWithDeprecatedFields {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ObjectWithDeprecatedFields
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ObjectWithDeprecatedFields
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Order.js b/samples/client/petstore/javascript-es6/src/model/Order.js
index 1d28748e822..ad586f185d4 100644
--- a/samples/client/petstore/javascript-es6/src/model/Order.js
+++ b/samples/client/petstore/javascript-es6/src/model/Order.js
@@ -69,9 +69,25 @@ class Order {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Order
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Order
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/OuterComposite.js b/samples/client/petstore/javascript-es6/src/model/OuterComposite.js
index cc4ed6c172d..1c6a3c9a857 100644
--- a/samples/client/petstore/javascript-es6/src/model/OuterComposite.js
+++ b/samples/client/petstore/javascript-es6/src/model/OuterComposite.js
@@ -60,9 +60,25 @@ class OuterComposite {
return obj;
}
+ /**
+ * Validates the JSON data with respect to OuterComposite
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to OuterComposite
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/OuterObjectWithEnumProperty.js b/samples/client/petstore/javascript-es6/src/model/OuterObjectWithEnumProperty.js
index d2ef0e04371..b9ead482af5 100644
--- a/samples/client/petstore/javascript-es6/src/model/OuterObjectWithEnumProperty.js
+++ b/samples/client/petstore/javascript-es6/src/model/OuterObjectWithEnumProperty.js
@@ -57,9 +57,27 @@ class OuterObjectWithEnumProperty {
return obj;
}
+ /**
+ * Validates the JSON data with respect to OuterObjectWithEnumProperty
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to OuterObjectWithEnumProperty
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Pet.js b/samples/client/petstore/javascript-es6/src/model/Pet.js
index b88e5d869f6..cc5239c6a17 100644
--- a/samples/client/petstore/javascript-es6/src/model/Pet.js
+++ b/samples/client/petstore/javascript-es6/src/model/Pet.js
@@ -75,9 +75,53 @@ class Pet {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Pet
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Pet
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Pig.js b/samples/client/petstore/javascript-es6/src/model/Pig.js
new file mode 100644
index 00000000000..45f822e0276
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/src/model/Pig.js
@@ -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 Pig
.
+ * @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 Pig
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 Pig
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 BasquePig
, DanishPig
.
+ * @return {(module:model/BasquePig|module:model/DanishPig)} The actual instance.
+ */
+ getActualInstance() {
+ return this.actualInstance;
+ }
+
+ /**
+ * Sets the actaul instance, which can be BasquePig
, DanishPig
.
+ * @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;
+
diff --git a/samples/client/petstore/javascript-es6/src/model/ReadOnlyFirst.js b/samples/client/petstore/javascript-es6/src/model/ReadOnlyFirst.js
index 8e2a39cf2ae..b0fa7628f16 100644
--- a/samples/client/petstore/javascript-es6/src/model/ReadOnlyFirst.js
+++ b/samples/client/petstore/javascript-es6/src/model/ReadOnlyFirst.js
@@ -57,9 +57,29 @@ class ReadOnlyFirst {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ReadOnlyFirst
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ReadOnlyFirst
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Return.js b/samples/client/petstore/javascript-es6/src/model/Return.js
index 304ebb46f04..616574b5fc3 100644
--- a/samples/client/petstore/javascript-es6/src/model/Return.js
+++ b/samples/client/petstore/javascript-es6/src/model/Return.js
@@ -55,9 +55,21 @@ class Return {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Return
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Return
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Number} return
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/SpecialModelName.js b/samples/client/petstore/javascript-es6/src/model/SpecialModelName.js
index 45ba7d7ea09..b9ece722920 100644
--- a/samples/client/petstore/javascript-es6/src/model/SpecialModelName.js
+++ b/samples/client/petstore/javascript-es6/src/model/SpecialModelName.js
@@ -54,9 +54,21 @@ class SpecialModelName {
return obj;
}
+ /**
+ * Validates the JSON data with respect to SpecialModelName
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to SpecialModelName
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Number} $special[property.name]
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/Tag.js b/samples/client/petstore/javascript-es6/src/model/Tag.js
index 3330530c0c2..c24706b827e 100644
--- a/samples/client/petstore/javascript-es6/src/model/Tag.js
+++ b/samples/client/petstore/javascript-es6/src/model/Tag.js
@@ -57,9 +57,25 @@ class Tag {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Tag
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Tag
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/src/model/User.js b/samples/client/petstore/javascript-es6/src/model/User.js
index 473bf7c78bc..145851f479b 100644
--- a/samples/client/petstore/javascript-es6/src/model/User.js
+++ b/samples/client/petstore/javascript-es6/src/model/User.js
@@ -75,9 +75,45 @@ class User {
return obj;
}
+ /**
+ * Validates the JSON data with respect to User
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to User
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-es6/test/PetstoreTest.js b/samples/client/petstore/javascript-es6/test/PetstoreTest.js
new file mode 100644
index 00000000000..61596656f14
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/test/PetstoreTest.js
@@ -0,0 +1,199 @@
+if (typeof module === 'object' && module.exports) {
+ var expect = require('expect.js');
+ var OpenAPIPetstore = require('../src/index');
+ var sinon = require('sinon');
+}
+
+var apiClient = OpenAPIPetstore.ApiClient.instance;
+
+var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+}
+
+var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+}
+
+describe('Petstore', function() {
+ describe('models', function() {
+ it('should serialize oneOf models correctly', function() {
+ var pig = new OpenAPIPetstore.Pig();
+ expect(JSON.stringify(pig)).to.be('null');
+
+ // set basque big as the payload
+ var bpig = new OpenAPIPetstore.BasquePig();
+ setProperty(bpig, "setClassName", "className", "BasquePig");
+ setProperty(bpig, "setColor", "color", "red");
+ expect(JSON.stringify(bpig)).to.be('{"className":"BasquePig","color":"red"}');
+
+ pig.setActualInstance(bpig);
+ expect(JSON.stringify(pig)).to.be('{"className":"BasquePig","color":"red"}');
+
+ });
+
+ it('should serialize nested oneOf models correctly', function() {
+ var nested_one_of = new OpenAPIPetstore.NestedOneOf();
+ setProperty(nested_one_of, "setSize", "size", 28);
+ expect(JSON.stringify(nested_one_of)).to.be('{"size":28}');
+
+ // set nested oneOf `Pig`
+ var pig = new OpenAPIPetstore.Pig();
+ // set basque big as the payload
+ var bpig = new OpenAPIPetstore.BasquePig();
+ setProperty(bpig, "setClassName", "className", "BasquePig");
+ setProperty(bpig, "setColor", "color", "red");
+ pig.setActualInstance(bpig);
+ setProperty(nested_one_of, "setNestedPig", "nested_pig", pig);
+
+ expect(JSON.stringify(nested_one_of)).to.be('{"size":28,"nested_pig":{"className":"BasquePig","color":"red"}}');
+ });
+
+ it('should run BasquePig constructFromObject correctly', function() {
+ var bpig_json = '{"className":"BasquePig","color":"red"}';
+ var bpig = OpenAPIPetstore.BasquePig.constructFromObject(JSON.parse(bpig_json), null);
+ expect(JSON.stringify(bpig)).to.be('{"className":"BasquePig","color":"red"}');
+
+ OpenAPIPetstore.BasquePig.validateJSON(JSON.parse(bpig_json)); // should not throw error
+ });
+
+ it('should throw error from Pet.validateJSON', function() {
+ var bpig_json = '{"className":"BasquePig","color":"red"}';
+ try {
+ OpenAPIPetstore.Pet.validateJSON(JSON.parse(bpig_json));
+ expect(true).to.be(false); // this line should not run if the error is thrown correctly
+ } catch (err) {
+ expect(err).to.be.eql(new Error('The required field `name` is not found in the JSON data: {"className":"BasquePig","color":"red"}'));
+ }
+ });
+
+ it('should run Pig constructFromObject correctly', function() {
+ var bpig = '{"className":"BasquePig","color":"red"}';
+ var pig = OpenAPIPetstore.Pig.constructFromObject(JSON.parse(bpig));
+ expect(JSON.stringify(pig)).to.be('{"className":"BasquePig","color":"red"}');
+ });
+
+ it('should throw an error when running Pig constructFromObject with incorrect data', function() {
+ try {
+ var bpig = '[1,2,3]';
+ var pig = OpenAPIPetstore.Pig.constructFromObject(JSON.parse(bpig));
+ } catch (err) {
+ expect(err).to.be.eql(new Error('No match found constructing `Pig` with oneOf schemas BasquePig, DanishPig. Details: Failed to construct BasquePig: Error: The required field `className` is not found in the JSON data: [1,2,3], Failed to construct DanishPig: Error: The required field `className` is not found in the JSON data: [1,2,3]'));
+ }
+ });
+
+ it('should deserialize simple models correctly', function() {
+ var tag_json = '{"id":1,"name":"tag_name"}';
+ var tag_result = OpenAPIPetstore.ApiClient.convertToType(tag_json, OpenAPIPetstore.Tag);
+ expect(tag_result).to.be.a(OpenAPIPetstore.Tag);
+ //expect(tag_result.id).to.be(1);
+ //expect(JSON.stringify(tag_result)).to.be(tag_json);
+ });
+
+ it('should deserialize nested oneOf models correctly', function() {
+ var nested_one_of_json = '{"size":28,"nested_pig":{"className":"BasquePig","color":"red"}}'
+ var result = OpenAPIPetstore.ApiClient.convertToType(JSON.parse(nested_one_of_json), OpenAPIPetstore.NestedOneOf);
+ expect(result).to.be.a(OpenAPIPetstore.NestedOneOf);
+ expect(JSON.stringify(result)).to.be(nested_one_of_json);
+ });
+
+ it('should run Color constructFromObject correctly from array', function() {
+ // construct from RgbColor
+ let array_integer = [0,128,255];
+ let color = OpenAPIPetstore.Color.constructFromObject(array_integer, null);
+ expect(color).to.be.a(OpenAPIPetstore.Color);
+ expect(color.getActualInstance()).to.be.eql(array_integer);
+ });
+
+ it('should throw an error when running Color constructFromObject with invalid array', function() {
+ // construct from RgbColor
+ let array_integer = [0,128,9255];
+ try {
+ let color = OpenAPIPetstore.Color.constructFromObject(array_integer, null);
+ expect(true).to.be(false); // this line should not run if the error is thrown correctly
+ } catch (err) {
+ expect(err).to.be.eql(new Error('No match found constructing `Color` with oneOf schemas String, [Number]. Details: Failed to construct [Number]: Error: Invalid integer value in an array items. Max.: 255. Min.: 0. Data: 0,128,9255, Failed to construct [Number]: Error: Invalid array size. Minimim: 4. Maximum: 4. Data: 0,128,9255, Failed to construct String: Error: Invalid data. Must be string. Data: [0,128,9255]'));
+ }
+ });
+
+ it('should run Color constructFromObject correctly', function() {
+ // valid hex color
+ var json = '"#00FF00"';
+ var color = OpenAPIPetstore.Color.constructFromObject(JSON.parse(json), null);
+ expect(JSON.stringify(color)).to.be(json);
+
+ // valid RgbColor
+ json = '[0,128,255]';
+ color = OpenAPIPetstore.Color.constructFromObject(JSON.parse(json), null);
+ expect(JSON.stringify(color)).to.be(json);
+
+ // valid RgbaColor
+ json = '[0,128,200,255]';
+ color = OpenAPIPetstore.Color.constructFromObject(JSON.parse(json), null);
+ expect(JSON.stringify(color)).to.be(json);
+ });
+
+ it('should thrown an error when running Color constructFromObject with invalid data', function() {
+ // invalid hex color
+ try {
+ let json = '"#00FF00ZZZZ"';
+ OpenAPIPetstore.Color.constructFromObject(JSON.parse(json), null);
+ expect(true).to.be(false); // this line should not run if the error is thrown correctly
+ } catch (err) {
+ expect(err).to.be.eql(new Error('No match found constructing Color with oneOf schemas String, [Number]. Details: Failed to desserialize JSON data into [Number]: Error: Invalid data type. Expecting array. Data: #00FF00ZZZZ, Failed to desserialize JSON data into [Number]: Error: Invalid data type. Expecting array. Data: #00FF00ZZZZ, Failed to desserialize JSON data into String: Error: Invalid string value in an array items. Must conform to /^#(?:[0-9a-fA-F]{3}){1,2}$/. Data: "#00FF00ZZZZ"'));
+ }
+
+ // invalid RgbColor <0
+ try {
+ let json = '[-1,128,255]';
+ OpenAPIPetstore.Color.constructFromObject(JSON.parse(json), null);
+ expect(true).to.be(false); // this line should not run if the error is thrown correctly
+ } catch (err) {
+ expect(err).to.be.eql(new Error('No match found constructing Color with oneOf schemas String, [Number]. Details: Failed to desserialize JSON data into [Number]: Error: Invalid integer value in an array items. Max.: 255. Min.: 0. Data: -1,128,255, Failed to desserialize JSON data into [Number]: Error: Invalid array size. Minimim: 4. Maximum: 4. Data: -1,128,255, Failed to desserialize JSON data into String: Error: Invalid data. Must be string. Data: [-1,128,255]'));
+ }
+
+ // invalid RgbColor >255
+ try {
+ let json = '[1,128,256]';
+ OpenAPIPetstore.Color.constructFromObject(JSON.parse(json), null);
+ expect(true).to.be(false); // this line should not run if the error is thrown correctly
+ } catch (err) {
+ expect(err).to.be.eql(new Error('No match found constructing Color with oneOf schemas String, [Number]. Details: Failed to desserialize JSON data into [Number]: Error: Invalid integer value in an array items. Max.: 255. Min.: 0. Data: 1,128,256, Failed to desserialize JSON data into [Number]: Error: Invalid array size. Minimim: 4. Maximum: 4. Data: 1,128,256, Failed to desserialize JSON data into String: Error: Invalid data. Must be string. Data: [1,128,256]'));
+ }
+
+ // invalid RgbaColor <0
+ try {
+ let json = '[-1,1,128,255]';
+ OpenAPIPetstore.Color.constructFromObject(JSON.parse(json), null);
+ expect(true).to.be(false); // this line should not run if the error is thrown correctly
+ } catch (err) {
+ expect(err).to.be.eql(new Error('No match found constructing Color with oneOf schemas String, [Number]. Details: Failed to desserialize JSON data into [Number]: Error: Invalid array size. Minimim: 3. Maximum: 3. Data: -1,1,128,255, Failed to desserialize JSON data into [Number]: Error: Invalid integer value in an array items. Max.: 255. Min.: 0. Data: -1,1,128,255, Failed to desserialize JSON data into String: Error: Invalid data. Must be string. Data: [-1,1,128,255]'));
+ }
+
+ // invalid RgbaColor >255
+ try {
+ let json = '[1,11,128,256]';
+ OpenAPIPetstore.Color.constructFromObject(JSON.parse(json), null);
+ expect(true).to.be(false); // this line should not run if the error is thrown correctly
+ } catch (err) {
+ expect(err).to.be.eql(new Error('[Error: No match found constructing Color with oneOf schemas String, [Number]. Details: Failed to desserialize JSON data into [Number]: Error: Invalid array size. Minimim: 3. Maximum: 3. Data: 1,11,128,256, Failed to desserialize JSON data into [Number]: Error: Invalid integer value in an array items. Max.: 255. Min.: 0. Data: 1,11,128,256, Failed to desserialize JSON data into String: Error: Invalid data. Must be string. Data: [1,11,128,256]'));
+ }
+ });
+
+ it('should deserialize nested oneOf models correctly', function() {
+ var json = '{"nested":"#00FF00","size":256}'
+ var result = OpenAPIPetstore.ApiClient.convertToType(JSON.parse(json), OpenAPIPetstore.NestedColor);
+ expect(result).to.be.a(OpenAPIPetstore.NestedColor);
+ expect(JSON.stringify(result)).to.be('{"size":256,"nested":"#00FF00"}');
+ });
+
+ });
+});
+
diff --git a/samples/client/petstore/javascript-es6/test/api/PetApi.spec.js b/samples/client/petstore/javascript-es6/test/api/PetApi.spec.js
index 49dcc060581..e21aa53f7d2 100644
--- a/samples/client/petstore/javascript-es6/test/api/PetApi.spec.js
+++ b/samples/client/petstore/javascript-es6/test/api/PetApi.spec.js
@@ -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"));
diff --git a/samples/client/petstore/javascript-es6/test/model/BasquePig.spec.js b/samples/client/petstore/javascript-es6/test/model/BasquePig.spec.js
new file mode 100644
index 00000000000..da5196fc092
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/test/model/BasquePig.spec.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.BasquePig();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('BasquePig', function() {
+ it('should create an instance of BasquePig', function() {
+ // uncomment below and update the code to test BasquePig
+ //var instance = new OpenApiPetstore.BasquePig();
+ //expect(instance).to.be.a(OpenApiPetstore.BasquePig);
+ });
+
+ it('should have the property className (base name: "className")', function() {
+ // uncomment below and update the code to test the property className
+ //var instance = new OpenApiPetstore.BasquePig();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property color (base name: "color")', function() {
+ // uncomment below and update the code to test the property color
+ //var instance = new OpenApiPetstore.BasquePig();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-es6/test/model/Color.spec.js b/samples/client/petstore/javascript-es6/test/model/Color.spec.js
new file mode 100644
index 00000000000..f203fe44d25
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/test/model/Color.spec.js
@@ -0,0 +1,59 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ //instance = new OpenApiPetstore.Color('#00FF00');
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('Color', function() {
+ it('should create an instance of Color', function() {
+ // uncomment below and update the code to test Color
+ //var instance = new OpenApiPetstore.Color();
+ //expect(instance).to.be.a(OpenApiPetstore.Color);
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-es6/test/model/DanishPig.spec.js b/samples/client/petstore/javascript-es6/test/model/DanishPig.spec.js
new file mode 100644
index 00000000000..f2272918461
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/test/model/DanishPig.spec.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.DanishPig();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('DanishPig', function() {
+ it('should create an instance of DanishPig', function() {
+ // uncomment below and update the code to test DanishPig
+ //var instance = new OpenApiPetstore.DanishPig();
+ //expect(instance).to.be.a(OpenApiPetstore.DanishPig);
+ });
+
+ it('should have the property className (base name: "className")', function() {
+ // uncomment below and update the code to test the property className
+ //var instance = new OpenApiPetstore.DanishPig();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property size (base name: "size")', function() {
+ // uncomment below and update the code to test the property size
+ //var instance = new OpenApiPetstore.DanishPig();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-es6/test/model/NestedColor.spec.js b/samples/client/petstore/javascript-es6/test/model/NestedColor.spec.js
new file mode 100644
index 00000000000..00a5813236d
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/test/model/NestedColor.spec.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.NestedColor();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('NestedColor', function() {
+ it('should create an instance of NestedColor', function() {
+ // uncomment below and update the code to test NestedColor
+ //var instance = new OpenApiPetstore.NestedColor();
+ //expect(instance).to.be.a(OpenApiPetstore.NestedColor);
+ });
+
+ it('should have the property size (base name: "size")', function() {
+ // uncomment below and update the code to test the property size
+ //var instance = new OpenApiPetstore.NestedColor();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property nested (base name: "nested")', function() {
+ // uncomment below and update the code to test the property nested
+ //var instance = new OpenApiPetstore.NestedColor();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-es6/test/model/NestedOneOf.spec.js b/samples/client/petstore/javascript-es6/test/model/NestedOneOf.spec.js
new file mode 100644
index 00000000000..5a54e7fbb08
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/test/model/NestedOneOf.spec.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.NestedOneOf();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('NestedOneOf', function() {
+ it('should create an instance of NestedOneOf', function() {
+ // uncomment below and update the code to test NestedOneOf
+ //var instance = new OpenApiPetstore.NestedOneOf();
+ //expect(instance).to.be.a(OpenApiPetstore.NestedOneOf);
+ });
+
+ it('should have the property size (base name: "size")', function() {
+ // uncomment below and update the code to test the property size
+ //var instance = new OpenApiPetstore.NestedOneOf();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property nestedPig (base name: "nested_pig")', function() {
+ // uncomment below and update the code to test the property nestedPig
+ //var instance = new OpenApiPetstore.NestedOneOf();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-es6/test/model/Pig.spec.js b/samples/client/petstore/javascript-es6/test/model/Pig.spec.js
new file mode 100644
index 00000000000..994a590578e
--- /dev/null
+++ b/samples/client/petstore/javascript-es6/test/model/Pig.spec.js
@@ -0,0 +1,77 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.Pig();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('Pig', function() {
+ it('should create an instance of Pig', function() {
+ // uncomment below and update the code to test Pig
+ //var instance = new OpenApiPetstore.Pig();
+ //expect(instance).to.be.a(OpenApiPetstore.Pig);
+ });
+
+ it('should have the property className (base name: "className")', function() {
+ // uncomment below and update the code to test the property className
+ //var instance = new OpenApiPetstore.Pig();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property color (base name: "color")', function() {
+ // uncomment below and update the code to test the property color
+ //var instance = new OpenApiPetstore.Pig();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property size (base name: "size")', function() {
+ // uncomment below and update the code to test the property size
+ //var instance = new OpenApiPetstore.Pig();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-promise-es6/.openapi-generator/FILES b/samples/client/petstore/javascript-promise-es6/.openapi-generator/FILES
index 0440bb2716c..f83260318a5 100644
--- a/samples/client/petstore/javascript-promise-es6/.openapi-generator/FILES
+++ b/samples/client/petstore/javascript-promise-es6/.openapi-generator/FILES
@@ -9,12 +9,15 @@ docs/ApiResponse.md
docs/ArrayOfArrayOfNumberOnly.md
docs/ArrayOfNumberOnly.md
docs/ArrayTest.md
+docs/BasquePig.md
docs/Capitalization.md
docs/Cat.md
docs/CatAllOf.md
docs/Category.md
docs/ClassModel.md
docs/Client.md
+docs/Color.md
+docs/DanishPig.md
docs/DefaultApi.md
docs/DeprecatedObject.md
docs/Dog.md
@@ -36,6 +39,8 @@ docs/MapTest.md
docs/MixedPropertiesAndAdditionalPropertiesClass.md
docs/Model200Response.md
docs/Name.md
+docs/NestedColor.md
+docs/NestedOneOf.md
docs/NullableClass.md
docs/NumberOnly.md
docs/ObjectWithDeprecatedFields.md
@@ -48,6 +53,7 @@ docs/OuterEnumIntegerDefaultValue.md
docs/OuterObjectWithEnumProperty.md
docs/Pet.md
docs/PetApi.md
+docs/Pig.md
docs/ReadOnlyFirst.md
docs/Return.md
docs/SpecialModelName.md
@@ -73,12 +79,15 @@ src/model/ApiResponse.js
src/model/ArrayOfArrayOfNumberOnly.js
src/model/ArrayOfNumberOnly.js
src/model/ArrayTest.js
+src/model/BasquePig.js
src/model/Capitalization.js
src/model/Cat.js
src/model/CatAllOf.js
src/model/Category.js
src/model/ClassModel.js
src/model/Client.js
+src/model/Color.js
+src/model/DanishPig.js
src/model/DeprecatedObject.js
src/model/Dog.js
src/model/DogAllOf.js
@@ -97,6 +106,8 @@ src/model/MapTest.js
src/model/MixedPropertiesAndAdditionalPropertiesClass.js
src/model/Model200Response.js
src/model/Name.js
+src/model/NestedColor.js
+src/model/NestedOneOf.js
src/model/NullableClass.js
src/model/NumberOnly.js
src/model/ObjectWithDeprecatedFields.js
@@ -108,6 +119,7 @@ src/model/OuterEnumInteger.js
src/model/OuterEnumIntegerDefaultValue.js
src/model/OuterObjectWithEnumProperty.js
src/model/Pet.js
+src/model/Pig.js
src/model/ReadOnlyFirst.js
src/model/Return.js
src/model/SpecialModelName.js
diff --git a/samples/client/petstore/javascript-promise-es6/README.md b/samples/client/petstore/javascript-promise-es6/README.md
index a968da472da..47a8d3c3453 100644
--- a/samples/client/petstore/javascript-promise-es6/README.md
+++ b/samples/client/petstore/javascript-promise-es6/README.md
@@ -169,12 +169,15 @@ Class | Method | HTTP request | Description
- [OpenApiPetstore.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
- [OpenApiPetstore.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [OpenApiPetstore.ArrayTest](docs/ArrayTest.md)
+ - [OpenApiPetstore.BasquePig](docs/BasquePig.md)
- [OpenApiPetstore.Capitalization](docs/Capitalization.md)
- [OpenApiPetstore.Cat](docs/Cat.md)
- [OpenApiPetstore.CatAllOf](docs/CatAllOf.md)
- [OpenApiPetstore.Category](docs/Category.md)
- [OpenApiPetstore.ClassModel](docs/ClassModel.md)
- [OpenApiPetstore.Client](docs/Client.md)
+ - [OpenApiPetstore.Color](docs/Color.md)
+ - [OpenApiPetstore.DanishPig](docs/DanishPig.md)
- [OpenApiPetstore.DeprecatedObject](docs/DeprecatedObject.md)
- [OpenApiPetstore.Dog](docs/Dog.md)
- [OpenApiPetstore.DogAllOf](docs/DogAllOf.md)
@@ -193,6 +196,8 @@ Class | Method | HTTP request | Description
- [OpenApiPetstore.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
- [OpenApiPetstore.Model200Response](docs/Model200Response.md)
- [OpenApiPetstore.Name](docs/Name.md)
+ - [OpenApiPetstore.NestedColor](docs/NestedColor.md)
+ - [OpenApiPetstore.NestedOneOf](docs/NestedOneOf.md)
- [OpenApiPetstore.NullableClass](docs/NullableClass.md)
- [OpenApiPetstore.NumberOnly](docs/NumberOnly.md)
- [OpenApiPetstore.ObjectWithDeprecatedFields](docs/ObjectWithDeprecatedFields.md)
@@ -204,6 +209,7 @@ Class | Method | HTTP request | Description
- [OpenApiPetstore.OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md)
- [OpenApiPetstore.OuterObjectWithEnumProperty](docs/OuterObjectWithEnumProperty.md)
- [OpenApiPetstore.Pet](docs/Pet.md)
+ - [OpenApiPetstore.Pig](docs/Pig.md)
- [OpenApiPetstore.ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [OpenApiPetstore.Return](docs/Return.md)
- [OpenApiPetstore.SpecialModelName](docs/SpecialModelName.md)
diff --git a/samples/client/petstore/javascript-promise-es6/docs/BasquePig.md b/samples/client/petstore/javascript-promise-es6/docs/BasquePig.md
new file mode 100644
index 00000000000..77d1e74bc71
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/docs/BasquePig.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.BasquePig
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**className** | **String** | |
+**color** | **String** | |
+
+
diff --git a/samples/client/petstore/javascript-promise-es6/docs/Color.md b/samples/client/petstore/javascript-promise-es6/docs/Color.md
new file mode 100644
index 00000000000..5f0e6f0dfba
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/docs/Color.md
@@ -0,0 +1,8 @@
+# OpenApiPetstore.Color
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+
+
diff --git a/samples/client/petstore/javascript-promise-es6/docs/DanishPig.md b/samples/client/petstore/javascript-promise-es6/docs/DanishPig.md
new file mode 100644
index 00000000000..7de3e60db36
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/docs/DanishPig.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.DanishPig
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**className** | **String** | |
+**size** | **Number** | |
+
+
diff --git a/samples/client/petstore/javascript-promise-es6/docs/NestedColor.md b/samples/client/petstore/javascript-promise-es6/docs/NestedColor.md
new file mode 100644
index 00000000000..aea6b444942
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/docs/NestedColor.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.NestedColor
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**size** | **Number** | | [optional]
+**nested** | [**Color**](Color.md) | | [optional]
+
+
diff --git a/samples/client/petstore/javascript-promise-es6/docs/NestedOneOf.md b/samples/client/petstore/javascript-promise-es6/docs/NestedOneOf.md
new file mode 100644
index 00000000000..b5228e89c70
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/docs/NestedOneOf.md
@@ -0,0 +1,10 @@
+# OpenApiPetstore.NestedOneOf
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**size** | **Number** | | [optional]
+**nestedPig** | [**Pig**](Pig.md) | | [optional]
+
+
diff --git a/samples/client/petstore/javascript-promise-es6/docs/Pig.md b/samples/client/petstore/javascript-promise-es6/docs/Pig.md
new file mode 100644
index 00000000000..a94e1687cc5
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/docs/Pig.md
@@ -0,0 +1,11 @@
+# OpenApiPetstore.Pig
+
+## Properties
+
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**className** | **String** | |
+**color** | **String** | |
+**size** | **Number** | |
+
+
diff --git a/samples/client/petstore/javascript-promise-es6/src/index.js b/samples/client/petstore/javascript-promise-es6/src/index.js
index 474899d9c51..a95a17ec1b0 100644
--- a/samples/client/petstore/javascript-promise-es6/src/index.js
+++ b/samples/client/petstore/javascript-promise-es6/src/index.js
@@ -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}
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/AdditionalPropertiesClass.js b/samples/client/petstore/javascript-promise-es6/src/model/AdditionalPropertiesClass.js
index d6d83cca284..3849c00c595 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/AdditionalPropertiesClass.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/AdditionalPropertiesClass.js
@@ -57,9 +57,21 @@ class AdditionalPropertiesClass {
return obj;
}
+ /**
+ * Validates the JSON data with respect to AdditionalPropertiesClass
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to AdditionalPropertiesClass
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Object.} map_property
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Animal.js b/samples/client/petstore/javascript-promise-es6/src/model/Animal.js
index 7cb9017160b..27c6975b599 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Animal.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Animal.js
@@ -59,9 +59,35 @@ class Animal {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Animal
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Animal
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/ApiResponse.js b/samples/client/petstore/javascript-promise-es6/src/model/ApiResponse.js
index f5af17fdf82..6db561122f1 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/ApiResponse.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/ApiResponse.js
@@ -60,9 +60,29 @@ class ApiResponse {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ApiResponse
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ApiResponse
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/ArrayOfArrayOfNumberOnly.js b/samples/client/petstore/javascript-promise-es6/src/model/ArrayOfArrayOfNumberOnly.js
index eadd7db414b..461c6b5b35b 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/ArrayOfArrayOfNumberOnly.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/ArrayOfArrayOfNumberOnly.js
@@ -54,9 +54,25 @@ class ArrayOfArrayOfNumberOnly {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ArrayOfArrayOfNumberOnly
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ArrayOfArrayOfNumberOnly
.
+ */
+ 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.>} ArrayArrayNumber
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/ArrayOfNumberOnly.js b/samples/client/petstore/javascript-promise-es6/src/model/ArrayOfNumberOnly.js
index 1145a62630d..4c2513c1076 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/ArrayOfNumberOnly.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/ArrayOfNumberOnly.js
@@ -54,9 +54,25 @@ class ArrayOfNumberOnly {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ArrayOfNumberOnly
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ArrayOfNumberOnly
.
+ */
+ 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.} ArrayNumber
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/ArrayTest.js b/samples/client/petstore/javascript-promise-es6/src/model/ArrayTest.js
index 18bc925308a..3fc3c9b7f92 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/ArrayTest.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/ArrayTest.js
@@ -61,9 +61,33 @@ class ArrayTest {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ArrayTest
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ArrayTest
.
+ */
+ 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.} array_of_string
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/BasquePig.js b/samples/client/petstore/javascript-promise-es6/src/model/BasquePig.js
new file mode 100644
index 00000000000..dc26c47c4fb
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/src/model/BasquePig.js
@@ -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 BasquePig
.
+ * @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 BasquePig
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 BasquePig
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 BasquePig
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to BasquePig
.
+ */
+ 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;
+
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Capitalization.js b/samples/client/petstore/javascript-promise-es6/src/model/Capitalization.js
index 63b14361fee..cf4ef4348ac 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Capitalization.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Capitalization.js
@@ -69,9 +69,45 @@ class Capitalization {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Capitalization
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Capitalization
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Cat.js b/samples/client/petstore/javascript-promise-es6/src/model/Cat.js
index d18ce94e70e..203a652cfc4 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Cat.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Cat.js
@@ -63,9 +63,27 @@ class Cat {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Cat
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Cat
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/CatAllOf.js b/samples/client/petstore/javascript-promise-es6/src/model/CatAllOf.js
index c71ea7129b0..8c0d5bfbbd4 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/CatAllOf.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/CatAllOf.js
@@ -54,9 +54,21 @@ class CatAllOf {
return obj;
}
+ /**
+ * Validates the JSON data with respect to CatAllOf
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to CatAllOf
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Boolean} declawed
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Category.js b/samples/client/petstore/javascript-promise-es6/src/model/Category.js
index 557e8e18620..fc304998f40 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Category.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Category.js
@@ -59,9 +59,31 @@ class Category {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Category
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Category
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/ClassModel.js b/samples/client/petstore/javascript-promise-es6/src/model/ClassModel.js
index ee1f1417777..ba614443ebf 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/ClassModel.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/ClassModel.js
@@ -55,9 +55,25 @@ class ClassModel {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ClassModel
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ClassModel
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Client.js b/samples/client/petstore/javascript-promise-es6/src/model/Client.js
index 8521c85043b..4089ff37ee6 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Client.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Client.js
@@ -54,9 +54,25 @@ class Client {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Client
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Client
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Color.js b/samples/client/petstore/javascript-promise-es6/src/model/Color.js
new file mode 100644
index 00000000000..759e5df97af
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Color.js
@@ -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 Color
.
+ * 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 Color
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 Color
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 String
, [Number]
.
+ * @return {(module:model/String|module:model/[Number])} The actual instance.
+ */
+ getActualInstance() {
+ return this.actualInstance;
+ }
+
+ /**
+ * Sets the actaul instance, which can be String
, [Number]
.
+ * @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;
+
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/DanishPig.js b/samples/client/petstore/javascript-promise-es6/src/model/DanishPig.js
new file mode 100644
index 00000000000..4023e9d637f
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/src/model/DanishPig.js
@@ -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 DanishPig
.
+ * @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 DanishPig
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 DanishPig
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 DanishPig
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to DanishPig
.
+ */
+ 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;
+
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/DeprecatedObject.js b/samples/client/petstore/javascript-promise-es6/src/model/DeprecatedObject.js
index c3298d50200..d7c874345f1 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/DeprecatedObject.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/DeprecatedObject.js
@@ -54,9 +54,25 @@ class DeprecatedObject {
return obj;
}
+ /**
+ * Validates the JSON data with respect to DeprecatedObject
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to DeprecatedObject
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Dog.js b/samples/client/petstore/javascript-promise-es6/src/model/Dog.js
index b101feecd32..dd3f1ebb509 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Dog.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Dog.js
@@ -63,9 +63,31 @@ class Dog {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Dog
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Dog
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/DogAllOf.js b/samples/client/petstore/javascript-promise-es6/src/model/DogAllOf.js
index 58ecede6126..beb42db2ec8 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/DogAllOf.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/DogAllOf.js
@@ -54,9 +54,25 @@ class DogAllOf {
return obj;
}
+ /**
+ * Validates the JSON data with respect to DogAllOf
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to DogAllOf
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/EnumArrays.js b/samples/client/petstore/javascript-promise-es6/src/model/EnumArrays.js
index 7fe64e3111a..2289689e349 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/EnumArrays.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/EnumArrays.js
@@ -57,9 +57,29 @@ class EnumArrays {
return obj;
}
+ /**
+ * Validates the JSON data with respect to EnumArrays
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to EnumArrays
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/EnumTest.js b/samples/client/petstore/javascript-promise-es6/src/model/EnumTest.js
index dc684b7c26b..b1556a0613f 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/EnumTest.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/EnumTest.js
@@ -81,9 +81,35 @@ class EnumTest {
return obj;
}
+ /**
+ * Validates the JSON data with respect to EnumTest
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to EnumTest
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/File.js b/samples/client/petstore/javascript-promise-es6/src/model/File.js
index 12b51b87d89..5f5c9547a1f 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/File.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/File.js
@@ -55,9 +55,25 @@ class File {
return obj;
}
+ /**
+ * Validates the JSON data with respect to File
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to File
.
+ */
+ 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
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/FileSchemaTestClass.js b/samples/client/petstore/javascript-promise-es6/src/model/FileSchemaTestClass.js
index b6fe9e90ece..8174d56245f 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/FileSchemaTestClass.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/FileSchemaTestClass.js
@@ -57,9 +57,35 @@ class FileSchemaTestClass {
return obj;
}
+ /**
+ * Validates the JSON data with respect to FileSchemaTestClass
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to FileSchemaTestClass
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Foo.js b/samples/client/petstore/javascript-promise-es6/src/model/Foo.js
index 3e4477b805b..3fc7819f99f 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Foo.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Foo.js
@@ -54,9 +54,25 @@ class Foo {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Foo
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Foo
.
+ */
+ 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'
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/FooGetDefaultResponse.js b/samples/client/petstore/javascript-promise-es6/src/model/FooGetDefaultResponse.js
index ab3558a0415..b11d8859371 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/FooGetDefaultResponse.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/FooGetDefaultResponse.js
@@ -55,9 +55,25 @@ class FooGetDefaultResponse {
return obj;
}
+ /**
+ * Validates the JSON data with respect to FooGetDefaultResponse
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to FooGetDefaultResponse
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/FormatTest.js b/samples/client/petstore/javascript-promise-es6/src/model/FormatTest.js
index 00ee3533d06..65a34a7ff09 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/FormatTest.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/FormatTest.js
@@ -107,9 +107,47 @@ class FormatTest {
return obj;
}
+ /**
+ * Validates the JSON data with respect to FormatTest
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to FormatTest
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/HasOnlyReadOnly.js b/samples/client/petstore/javascript-promise-es6/src/model/HasOnlyReadOnly.js
index 57c9173723e..90943b87aef 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/HasOnlyReadOnly.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/HasOnlyReadOnly.js
@@ -57,9 +57,29 @@ class HasOnlyReadOnly {
return obj;
}
+ /**
+ * Validates the JSON data with respect to HasOnlyReadOnly
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to HasOnlyReadOnly
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/HealthCheckResult.js b/samples/client/petstore/javascript-promise-es6/src/model/HealthCheckResult.js
index 2dd62c2a267..112fd778426 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/HealthCheckResult.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/HealthCheckResult.js
@@ -55,9 +55,25 @@ class HealthCheckResult {
return obj;
}
+ /**
+ * Validates the JSON data with respect to HealthCheckResult
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to HealthCheckResult
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/List.js b/samples/client/petstore/javascript-promise-es6/src/model/List.js
index 18d6a258491..ca916761c0f 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/List.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/List.js
@@ -54,9 +54,25 @@ class List {
return obj;
}
+ /**
+ * Validates the JSON data with respect to List
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to List
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/MapTest.js b/samples/client/petstore/javascript-promise-es6/src/model/MapTest.js
index 3113ad56bd4..478e2347fa7 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/MapTest.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/MapTest.js
@@ -63,9 +63,21 @@ class MapTest {
return obj;
}
+ /**
+ * Validates the JSON data with respect to MapTest
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to MapTest
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Object.>} map_map_of_string
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/MixedPropertiesAndAdditionalPropertiesClass.js b/samples/client/petstore/javascript-promise-es6/src/model/MixedPropertiesAndAdditionalPropertiesClass.js
index 7cd9ca844f9..8131fa36203 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/MixedPropertiesAndAdditionalPropertiesClass.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/MixedPropertiesAndAdditionalPropertiesClass.js
@@ -61,9 +61,25 @@ class MixedPropertiesAndAdditionalPropertiesClass {
return obj;
}
+ /**
+ * Validates the JSON data with respect to MixedPropertiesAndAdditionalPropertiesClass
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to MixedPropertiesAndAdditionalPropertiesClass
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Model200Response.js b/samples/client/petstore/javascript-promise-es6/src/model/Model200Response.js
index 88daaba2ebb..604683735fc 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Model200Response.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Model200Response.js
@@ -58,9 +58,25 @@ class Model200Response {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Model200Response
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Model200Response
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Name.js b/samples/client/petstore/javascript-promise-es6/src/model/Name.js
index 740d4bad15b..978fbaa7efe 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Name.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Name.js
@@ -66,9 +66,31 @@ class Name {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Name
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Name
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/NestedColor.js b/samples/client/petstore/javascript-promise-es6/src/model/NestedColor.js
new file mode 100644
index 00000000000..5b611469036
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/src/model/NestedColor.js
@@ -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 NestedColor
.
+ * @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 NestedColor
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 NestedColor
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 NestedColor
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to NestedColor
.
+ */
+ 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;
+
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/NestedOneOf.js b/samples/client/petstore/javascript-promise-es6/src/model/NestedOneOf.js
new file mode 100644
index 00000000000..3ea6ed798b7
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/src/model/NestedOneOf.js
@@ -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 NestedOneOf
.
+ * @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 NestedOneOf
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 NestedOneOf
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 NestedOneOf
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to NestedOneOf
.
+ */
+ 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;
+
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/NullableClass.js b/samples/client/petstore/javascript-promise-es6/src/model/NullableClass.js
index 12a0f2509b6..33dd77a1820 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/NullableClass.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/NullableClass.js
@@ -91,9 +91,37 @@ class NullableClass {
return obj;
}
+ /**
+ * Validates the JSON data with respect to NullableClass
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to NullableClass
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/NumberOnly.js b/samples/client/petstore/javascript-promise-es6/src/model/NumberOnly.js
index 449e08bd9a9..deb4f2961f6 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/NumberOnly.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/NumberOnly.js
@@ -54,9 +54,21 @@ class NumberOnly {
return obj;
}
+ /**
+ * Validates the JSON data with respect to NumberOnly
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to NumberOnly
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Number} JustNumber
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/ObjectWithDeprecatedFields.js b/samples/client/petstore/javascript-promise-es6/src/model/ObjectWithDeprecatedFields.js
index a3d0d400943..29e80fd2664 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/ObjectWithDeprecatedFields.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/ObjectWithDeprecatedFields.js
@@ -64,9 +64,33 @@ class ObjectWithDeprecatedFields {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ObjectWithDeprecatedFields
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ObjectWithDeprecatedFields
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Order.js b/samples/client/petstore/javascript-promise-es6/src/model/Order.js
index 1d28748e822..ad586f185d4 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Order.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Order.js
@@ -69,9 +69,25 @@ class Order {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Order
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Order
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/OuterComposite.js b/samples/client/petstore/javascript-promise-es6/src/model/OuterComposite.js
index cc4ed6c172d..1c6a3c9a857 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/OuterComposite.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/OuterComposite.js
@@ -60,9 +60,25 @@ class OuterComposite {
return obj;
}
+ /**
+ * Validates the JSON data with respect to OuterComposite
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to OuterComposite
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/OuterObjectWithEnumProperty.js b/samples/client/petstore/javascript-promise-es6/src/model/OuterObjectWithEnumProperty.js
index d2ef0e04371..b9ead482af5 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/OuterObjectWithEnumProperty.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/OuterObjectWithEnumProperty.js
@@ -57,9 +57,27 @@ class OuterObjectWithEnumProperty {
return obj;
}
+ /**
+ * Validates the JSON data with respect to OuterObjectWithEnumProperty
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to OuterObjectWithEnumProperty
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Pet.js b/samples/client/petstore/javascript-promise-es6/src/model/Pet.js
index b88e5d869f6..cc5239c6a17 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Pet.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Pet.js
@@ -75,9 +75,53 @@ class Pet {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Pet
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Pet
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Pig.js b/samples/client/petstore/javascript-promise-es6/src/model/Pig.js
new file mode 100644
index 00000000000..45f822e0276
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Pig.js
@@ -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 Pig
.
+ * @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 Pig
from a plain JavaScript object, optionally creating a new instance.
+ * Copies all relevant properties from data
to obj
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 Pig
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 BasquePig
, DanishPig
.
+ * @return {(module:model/BasquePig|module:model/DanishPig)} The actual instance.
+ */
+ getActualInstance() {
+ return this.actualInstance;
+ }
+
+ /**
+ * Sets the actaul instance, which can be BasquePig
, DanishPig
.
+ * @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;
+
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/ReadOnlyFirst.js b/samples/client/petstore/javascript-promise-es6/src/model/ReadOnlyFirst.js
index 8e2a39cf2ae..b0fa7628f16 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/ReadOnlyFirst.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/ReadOnlyFirst.js
@@ -57,9 +57,29 @@ class ReadOnlyFirst {
return obj;
}
+ /**
+ * Validates the JSON data with respect to ReadOnlyFirst
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to ReadOnlyFirst
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Return.js b/samples/client/petstore/javascript-promise-es6/src/model/Return.js
index 304ebb46f04..616574b5fc3 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Return.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Return.js
@@ -55,9 +55,21 @@ class Return {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Return
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Return
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Number} return
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/SpecialModelName.js b/samples/client/petstore/javascript-promise-es6/src/model/SpecialModelName.js
index 45ba7d7ea09..b9ece722920 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/SpecialModelName.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/SpecialModelName.js
@@ -54,9 +54,21 @@ class SpecialModelName {
return obj;
}
+ /**
+ * Validates the JSON data with respect to SpecialModelName
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to SpecialModelName
.
+ */
+ static validateJSON(data) {
+
+ return true;
+ }
+
}
+
+
/**
* @member {Number} $special[property.name]
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Tag.js b/samples/client/petstore/javascript-promise-es6/src/model/Tag.js
index 3330530c0c2..c24706b827e 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/Tag.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/Tag.js
@@ -57,9 +57,25 @@ class Tag {
return obj;
}
+ /**
+ * Validates the JSON data with respect to Tag
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to Tag
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/src/model/User.js b/samples/client/petstore/javascript-promise-es6/src/model/User.js
index 473bf7c78bc..145851f479b 100644
--- a/samples/client/petstore/javascript-promise-es6/src/model/User.js
+++ b/samples/client/petstore/javascript-promise-es6/src/model/User.js
@@ -75,9 +75,45 @@ class User {
return obj;
}
+ /**
+ * Validates the JSON data with respect to User
.
+ * @param {Object} data The plain JavaScript object bearing properties of interest.
+ * @return {boolean} to indicate whether the JSON data is valid with respect to User
.
+ */
+ 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
*/
diff --git a/samples/client/petstore/javascript-promise-es6/test/model/BasquePig.spec.js b/samples/client/petstore/javascript-promise-es6/test/model/BasquePig.spec.js
new file mode 100644
index 00000000000..da5196fc092
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/test/model/BasquePig.spec.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.BasquePig();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('BasquePig', function() {
+ it('should create an instance of BasquePig', function() {
+ // uncomment below and update the code to test BasquePig
+ //var instance = new OpenApiPetstore.BasquePig();
+ //expect(instance).to.be.a(OpenApiPetstore.BasquePig);
+ });
+
+ it('should have the property className (base name: "className")', function() {
+ // uncomment below and update the code to test the property className
+ //var instance = new OpenApiPetstore.BasquePig();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property color (base name: "color")', function() {
+ // uncomment below and update the code to test the property color
+ //var instance = new OpenApiPetstore.BasquePig();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-promise-es6/test/model/Color.spec.js b/samples/client/petstore/javascript-promise-es6/test/model/Color.spec.js
new file mode 100644
index 00000000000..c079e6e5111
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/test/model/Color.spec.js
@@ -0,0 +1,59 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.Color();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('Color', function() {
+ it('should create an instance of Color', function() {
+ // uncomment below and update the code to test Color
+ //var instance = new OpenApiPetstore.Color();
+ //expect(instance).to.be.a(OpenApiPetstore.Color);
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-promise-es6/test/model/DanishPig.spec.js b/samples/client/petstore/javascript-promise-es6/test/model/DanishPig.spec.js
new file mode 100644
index 00000000000..f2272918461
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/test/model/DanishPig.spec.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.DanishPig();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('DanishPig', function() {
+ it('should create an instance of DanishPig', function() {
+ // uncomment below and update the code to test DanishPig
+ //var instance = new OpenApiPetstore.DanishPig();
+ //expect(instance).to.be.a(OpenApiPetstore.DanishPig);
+ });
+
+ it('should have the property className (base name: "className")', function() {
+ // uncomment below and update the code to test the property className
+ //var instance = new OpenApiPetstore.DanishPig();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property size (base name: "size")', function() {
+ // uncomment below and update the code to test the property size
+ //var instance = new OpenApiPetstore.DanishPig();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-promise-es6/test/model/NestedColor.spec.js b/samples/client/petstore/javascript-promise-es6/test/model/NestedColor.spec.js
new file mode 100644
index 00000000000..00a5813236d
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/test/model/NestedColor.spec.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.NestedColor();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('NestedColor', function() {
+ it('should create an instance of NestedColor', function() {
+ // uncomment below and update the code to test NestedColor
+ //var instance = new OpenApiPetstore.NestedColor();
+ //expect(instance).to.be.a(OpenApiPetstore.NestedColor);
+ });
+
+ it('should have the property size (base name: "size")', function() {
+ // uncomment below and update the code to test the property size
+ //var instance = new OpenApiPetstore.NestedColor();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property nested (base name: "nested")', function() {
+ // uncomment below and update the code to test the property nested
+ //var instance = new OpenApiPetstore.NestedColor();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-promise-es6/test/model/NestedOneOf.spec.js b/samples/client/petstore/javascript-promise-es6/test/model/NestedOneOf.spec.js
new file mode 100644
index 00000000000..5a54e7fbb08
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/test/model/NestedOneOf.spec.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.NestedOneOf();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('NestedOneOf', function() {
+ it('should create an instance of NestedOneOf', function() {
+ // uncomment below and update the code to test NestedOneOf
+ //var instance = new OpenApiPetstore.NestedOneOf();
+ //expect(instance).to.be.a(OpenApiPetstore.NestedOneOf);
+ });
+
+ it('should have the property size (base name: "size")', function() {
+ // uncomment below and update the code to test the property size
+ //var instance = new OpenApiPetstore.NestedOneOf();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property nestedPig (base name: "nested_pig")', function() {
+ // uncomment below and update the code to test the property nestedPig
+ //var instance = new OpenApiPetstore.NestedOneOf();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));
diff --git a/samples/client/petstore/javascript-promise-es6/test/model/Pig.spec.js b/samples/client/petstore/javascript-promise-es6/test/model/Pig.spec.js
new file mode 100644
index 00000000000..994a590578e
--- /dev/null
+++ b/samples/client/petstore/javascript-promise-es6/test/model/Pig.spec.js
@@ -0,0 +1,77 @@
+/**
+ * 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.
+ *
+ */
+
+(function(root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD.
+ define(['expect.js', process.cwd()+'/src/index'], factory);
+ } else if (typeof module === 'object' && module.exports) {
+ // CommonJS-like environments that support module.exports, like Node.
+ factory(require('expect.js'), require(process.cwd()+'/src/index'));
+ } else {
+ // Browser globals (root is window)
+ factory(root.expect, root.OpenApiPetstore);
+ }
+}(this, function(expect, OpenApiPetstore) {
+ 'use strict';
+
+ var instance;
+
+ beforeEach(function() {
+ instance = new OpenApiPetstore.Pig();
+ });
+
+ var getProperty = function(object, getter, property) {
+ // Use getter method if present; otherwise, get the property directly.
+ if (typeof object[getter] === 'function')
+ return object[getter]();
+ else
+ return object[property];
+ }
+
+ var setProperty = function(object, setter, property, value) {
+ // Use setter method if present; otherwise, set the property directly.
+ if (typeof object[setter] === 'function')
+ object[setter](value);
+ else
+ object[property] = value;
+ }
+
+ describe('Pig', function() {
+ it('should create an instance of Pig', function() {
+ // uncomment below and update the code to test Pig
+ //var instance = new OpenApiPetstore.Pig();
+ //expect(instance).to.be.a(OpenApiPetstore.Pig);
+ });
+
+ it('should have the property className (base name: "className")', function() {
+ // uncomment below and update the code to test the property className
+ //var instance = new OpenApiPetstore.Pig();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property color (base name: "color")', function() {
+ // uncomment below and update the code to test the property color
+ //var instance = new OpenApiPetstore.Pig();
+ //expect(instance).to.be();
+ });
+
+ it('should have the property size (base name: "size")', function() {
+ // uncomment below and update the code to test the property size
+ //var instance = new OpenApiPetstore.Pig();
+ //expect(instance).to.be();
+ });
+
+ });
+
+}));