Created by: codeserk
This is a follow-up story that completes this PR proposed before. This PR adds a new parameter that has default value to false to maintain retro-compatibility.
Problem
The current implementation expands all the parameters in the API methods:
/**
*
* @summary Logs user into the system
* @param {string} username The user name for login
* @param {string} password The password for login in clear text
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
loginUser(username: string, password: string, options?: any): AxiosPromise<string> {
This is especially problematic when adding more fields to existing endpoints, since the order of the parameters might change. This leads to a breaking changes in the generated client, even if the API introduced a non-breaking change (a new optional parameter).
Proposal
Adding a new parameter useSingleRequestParameter
to combine all the request parameters in a single object. This is not a new solution, it has been implemented in other generators and there is already a proposed solution using this mechanism. This new option is disabled by default, to keep compatibility with previous versions
Interfaces for the requests
/**
* Request parameters for loginUser operation in UserApi.
* @export
* @interface UserApiLoginUserRequest
*/
export interface UserApiLoginUserRequest {
/**
* The user name for login
* @type {string}
* @memberof UserApiLoginUser
*/
readonly username: string
/**
* The password for login in clear text
* @type {string}
* @memberof UserApiLoginUser
*/
readonly password: string
}
Changes in the methods to use the request interfaces
/**
*
* @summary Logs user into the system
* @param {UserApiLoginUserRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof UserApi
*/
public loginUser(requestParameters: UserApiLoginUserRequest, options?: any) {
return UserApiFp(this.configuration).loginUser(requestParameters.username, requestParameters.password, options).then((request) => request(this.axios, this.basePath));
}
Review
I've split the changes in different commits to ease the review process. The last commit contains the highest number of changes: I've regenerated all the samples.
@macjohnny I believe you were the reviewer of the previous PR and asked for some changes in the previous proposal. Please let me know if there's something missing (I'm pretty new with mustache
and this is my first contribution to this project so I might have messed up something :D)
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @nicokoenig @topce @akehir @petejohansonxo @amakhrov