forked from loafle/openapi-generator-original
use model class for request body with additionalProperties (#16613)
* try out simple fix * add test case * generate samples
This commit is contained in:
@@ -20,6 +20,7 @@ import HealthCheckStatus from '../model/HealthCheckStatus';
|
||||
import OuterComposite from '../model/OuterComposite';
|
||||
import OuterObjectWithEnumProperty from '../model/OuterObjectWithEnumProperty';
|
||||
import Pet from '../model/Pet';
|
||||
import TestInlineFreeformAdditionalPropertiesRequest from '../model/TestInlineFreeformAdditionalPropertiesRequest';
|
||||
import User from '../model/User';
|
||||
|
||||
/**
|
||||
@@ -728,6 +729,47 @@ export default class FakeApi {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function to receive the result of the testInlineFreeformAdditionalProperties operation.
|
||||
* @callback module:api/FakeApi~testInlineFreeformAdditionalPropertiesCallback
|
||||
* @param {String} error Error message, if any.
|
||||
* @param data This operation does not return a value.
|
||||
* @param {String} response The complete HTTP response.
|
||||
*/
|
||||
|
||||
/**
|
||||
* test inline free-form additionalProperties
|
||||
*
|
||||
* @param {module:model/TestInlineFreeformAdditionalPropertiesRequest} testInlineFreeformAdditionalPropertiesRequest request body
|
||||
* @param {module:api/FakeApi~testInlineFreeformAdditionalPropertiesCallback} callback The callback function, accepting three arguments: error, data, response
|
||||
*/
|
||||
testInlineFreeformAdditionalProperties(testInlineFreeformAdditionalPropertiesRequest, callback) {
|
||||
let postBody = testInlineFreeformAdditionalPropertiesRequest;
|
||||
// verify the required parameter 'testInlineFreeformAdditionalPropertiesRequest' is set
|
||||
if (testInlineFreeformAdditionalPropertiesRequest === undefined || testInlineFreeformAdditionalPropertiesRequest === null) {
|
||||
throw new Error("Missing the required parameter 'testInlineFreeformAdditionalPropertiesRequest' when calling testInlineFreeformAdditionalProperties");
|
||||
}
|
||||
|
||||
let pathParams = {
|
||||
};
|
||||
let queryParams = {
|
||||
};
|
||||
let headerParams = {
|
||||
};
|
||||
let formParams = {
|
||||
};
|
||||
|
||||
let authNames = [];
|
||||
let contentTypes = ['application/json'];
|
||||
let accepts = [];
|
||||
let returnType = null;
|
||||
return this.apiClient.callApi(
|
||||
'/fake/inline-freeform-additionalProperties', 'POST',
|
||||
pathParams, queryParams, headerParams, formParams, postBody,
|
||||
authNames, contentTypes, accepts, returnType, null, callback
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function to receive the result of the testJsonFormData operation.
|
||||
* @callback module:api/FakeApi~testJsonFormDataCallback
|
||||
|
||||
@@ -63,6 +63,7 @@ import Return from './model/Return';
|
||||
import SpecialModelName from './model/SpecialModelName';
|
||||
import StringOrBoolean from './model/StringOrBoolean';
|
||||
import Tag from './model/Tag';
|
||||
import TestInlineFreeformAdditionalPropertiesRequest from './model/TestInlineFreeformAdditionalPropertiesRequest';
|
||||
import User from './model/User';
|
||||
import AnotherFakeApi from './api/AnotherFakeApi';
|
||||
import DefaultApi from './api/DefaultApi';
|
||||
@@ -411,6 +412,12 @@ export {
|
||||
*/
|
||||
Tag,
|
||||
|
||||
/**
|
||||
* The TestInlineFreeformAdditionalPropertiesRequest model constructor.
|
||||
* @property {module:model/TestInlineFreeformAdditionalPropertiesRequest}
|
||||
*/
|
||||
TestInlineFreeformAdditionalPropertiesRequest,
|
||||
|
||||
/**
|
||||
* The User model constructor.
|
||||
* @property {module:model/User}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* 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 TestInlineFreeformAdditionalPropertiesRequest model module.
|
||||
* @module model/TestInlineFreeformAdditionalPropertiesRequest
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class TestInlineFreeformAdditionalPropertiesRequest {
|
||||
/**
|
||||
* Constructs a new <code>TestInlineFreeformAdditionalPropertiesRequest</code>.
|
||||
* @alias module:model/TestInlineFreeformAdditionalPropertiesRequest
|
||||
* @extends Object
|
||||
*/
|
||||
constructor() {
|
||||
|
||||
TestInlineFreeformAdditionalPropertiesRequest.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>TestInlineFreeformAdditionalPropertiesRequest</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/TestInlineFreeformAdditionalPropertiesRequest} obj Optional instance to populate.
|
||||
* @return {module:model/TestInlineFreeformAdditionalPropertiesRequest} The populated <code>TestInlineFreeformAdditionalPropertiesRequest</code> instance.
|
||||
*/
|
||||
static constructFromObject(data, obj) {
|
||||
if (data) {
|
||||
obj = obj || new TestInlineFreeformAdditionalPropertiesRequest();
|
||||
|
||||
ApiClient.constructFromObject(data, obj, 'Object');
|
||||
|
||||
|
||||
if (data.hasOwnProperty('someProperty')) {
|
||||
obj['someProperty'] = ApiClient.convertToType(data['someProperty'], 'String');
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON data with respect to <code>TestInlineFreeformAdditionalPropertiesRequest</code>.
|
||||
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
||||
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>TestInlineFreeformAdditionalPropertiesRequest</code>.
|
||||
*/
|
||||
static validateJSON(data) {
|
||||
// ensure the json data is a string
|
||||
if (data['someProperty'] && !(typeof data['someProperty'] === 'string' || data['someProperty'] instanceof String)) {
|
||||
throw new Error("Expected the field `someProperty` to be a primitive type in the JSON string but got " + data['someProperty']);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @member {String} someProperty
|
||||
*/
|
||||
TestInlineFreeformAdditionalPropertiesRequest.prototype['someProperty'] = undefined;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export default TestInlineFreeformAdditionalPropertiesRequest;
|
||||
|
||||
Reference in New Issue
Block a user