handle composed schemas in InlineModelResolver (#2112)

* handle composed schemas in InlineModelResolver

* fix unit test -> TestUtils.parseSpec

* update samples

* fix samples

* update samples

* update samples

* add new files
This commit is contained in:
Matthieu Berthomé
2019-05-08 04:19:15 +02:00
committed by William Cheng
parent 7eb2be9c99
commit ee43cc1520
412 changed files with 17001 additions and 101 deletions

View File

@@ -175,10 +175,12 @@ Class | Method | HTTP request | Description
- [OpenApiPetstore.ArrayTest](docs/ArrayTest.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.Dog](docs/Dog.md)
- [OpenApiPetstore.DogAllOf](docs/DogAllOf.md)
- [OpenApiPetstore.EnumArrays](docs/EnumArrays.md)
- [OpenApiPetstore.EnumClass](docs/EnumClass.md)
- [OpenApiPetstore.EnumTest](docs/EnumTest.md)

View File

@@ -0,0 +1,9 @@
# OpenApiPetstore.CatAllOf
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**declawed** | **Boolean** | | [optional]

View File

@@ -0,0 +1,9 @@
# OpenApiPetstore.DogAllOf
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**breed** | **String** | | [optional]

View File

@@ -28,10 +28,12 @@ import ArrayOfNumberOnly from './model/ArrayOfNumberOnly';
import ArrayTest from './model/ArrayTest';
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 Dog from './model/Dog';
import DogAllOf from './model/DogAllOf';
import EnumArrays from './model/EnumArrays';
import EnumClass from './model/EnumClass';
import EnumTest from './model/EnumTest';
@@ -193,6 +195,12 @@ export {
*/
Cat,
/**
* The CatAllOf model constructor.
* @property {module:model/CatAllOf}
*/
CatAllOf,
/**
* The Category model constructor.
* @property {module:model/Category}
@@ -217,6 +225,12 @@ export {
*/
Dog,
/**
* The DogAllOf model constructor.
* @property {module:model/DogAllOf}
*/
DogAllOf,
/**
* The EnumArrays model constructor.
* @property {module:model/EnumArrays}

View File

@@ -13,6 +13,7 @@
import ApiClient from '../ApiClient';
import Animal from './Animal';
import CatAllOf from './CatAllOf';
/**
* The Cat model module.
@@ -25,10 +26,11 @@ class Cat {
* @alias module:model/Cat
* @extends module:model/Animal
* @implements module:model/Animal
* @implements module:model/CatAllOf
* @param className {String}
*/
constructor(className) {
Animal.initialize(this, className);
Animal.initialize(this, className);CatAllOf.initialize(this);
Cat.initialize(this, className);
}
@@ -52,6 +54,7 @@ class Cat {
obj = obj || new Cat();
Animal.constructFromObject(data, obj);
Animal.constructFromObject(data, obj);
CatAllOf.constructFromObject(data, obj);
if (data.hasOwnProperty('declawed')) {
obj['declawed'] = ApiClient.convertToType(data['declawed'], 'Boolean');
@@ -79,6 +82,11 @@ Animal.prototype['className'] = undefined;
* @default 'red'
*/
Animal.prototype['color'] = 'red';
// Implement CatAllOf interface:
/**
* @member {Boolean} declawed
*/
CatAllOf.prototype['declawed'] = undefined;

View File

@@ -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: \" \\
*
* OpenAPI spec version: 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 CatAllOf model module.
* @module model/CatAllOf
* @version 1.0.0
*/
class CatAllOf {
/**
* Constructs a new <code>CatAllOf</code>.
* @alias module:model/CatAllOf
*/
constructor() {
CatAllOf.initialize(this);
}
/**
* Initializes the fields of this object.
* This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
* Only for internal use.
*/
static initialize(obj) {
}
/**
* Constructs a <code>CatAllOf</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/CatAllOf} obj Optional instance to populate.
* @return {module:model/CatAllOf} The populated <code>CatAllOf</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new CatAllOf();
if (data.hasOwnProperty('declawed')) {
obj['declawed'] = ApiClient.convertToType(data['declawed'], 'Boolean');
}
}
return obj;
}
}
/**
* @member {Boolean} declawed
*/
CatAllOf.prototype['declawed'] = undefined;
export default CatAllOf;

View File

@@ -13,6 +13,7 @@
import ApiClient from '../ApiClient';
import Animal from './Animal';
import DogAllOf from './DogAllOf';
/**
* The Dog model module.
@@ -25,10 +26,11 @@ class Dog {
* @alias module:model/Dog
* @extends module:model/Animal
* @implements module:model/Animal
* @implements module:model/DogAllOf
* @param className {String}
*/
constructor(className) {
Animal.initialize(this, className);
Animal.initialize(this, className);DogAllOf.initialize(this);
Dog.initialize(this, className);
}
@@ -52,6 +54,7 @@ class Dog {
obj = obj || new Dog();
Animal.constructFromObject(data, obj);
Animal.constructFromObject(data, obj);
DogAllOf.constructFromObject(data, obj);
if (data.hasOwnProperty('breed')) {
obj['breed'] = ApiClient.convertToType(data['breed'], 'String');
@@ -79,6 +82,11 @@ Animal.prototype['className'] = undefined;
* @default 'red'
*/
Animal.prototype['color'] = 'red';
// Implement DogAllOf interface:
/**
* @member {String} breed
*/
DogAllOf.prototype['breed'] = undefined;

View File

@@ -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: \" \\
*
* OpenAPI spec version: 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 DogAllOf model module.
* @module model/DogAllOf
* @version 1.0.0
*/
class DogAllOf {
/**
* Constructs a new <code>DogAllOf</code>.
* @alias module:model/DogAllOf
*/
constructor() {
DogAllOf.initialize(this);
}
/**
* Initializes the fields of this object.
* This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
* Only for internal use.
*/
static initialize(obj) {
}
/**
* Constructs a <code>DogAllOf</code> from a plain JavaScript object, optionally creating a new instance.
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
* @param {Object} data The plain JavaScript object bearing properties of interest.
* @param {module:model/DogAllOf} obj Optional instance to populate.
* @return {module:model/DogAllOf} The populated <code>DogAllOf</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new DogAllOf();
if (data.hasOwnProperty('breed')) {
obj['breed'] = ApiClient.convertToType(data['breed'], 'String');
}
}
return obj;
}
}
/**
* @member {String} breed
*/
DogAllOf.prototype['breed'] = undefined;
export default DogAllOf;

View File

@@ -0,0 +1,65 @@
/**
* 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: \" \\
*
* OpenAPI spec version: 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.CatAllOf();
});
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('CatAllOf', function() {
it('should create an instance of CatAllOf', function() {
// uncomment below and update the code to test CatAllOf
//var instane = new OpenApiPetstore.CatAllOf();
//expect(instance).to.be.a(OpenApiPetstore.CatAllOf);
});
it('should have the property declawed (base name: "declawed")', function() {
// uncomment below and update the code to test the property declawed
//var instane = new OpenApiPetstore.CatAllOf();
//expect(instance).to.be();
});
});
}));

View File

@@ -0,0 +1,65 @@
/**
* 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: \" \\
*
* OpenAPI spec version: 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.DogAllOf();
});
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('DogAllOf', function() {
it('should create an instance of DogAllOf', function() {
// uncomment below and update the code to test DogAllOf
//var instane = new OpenApiPetstore.DogAllOf();
//expect(instance).to.be.a(OpenApiPetstore.DogAllOf);
});
it('should have the property breed (base name: "breed")', function() {
// uncomment below and update the code to test the property breed
//var instane = new OpenApiPetstore.DogAllOf();
//expect(instance).to.be();
});
});
}));