-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
I generated my first client and was disappointed to get a method with 15 arguments. This seems like it should be a single object conforming to an interface. It would be especially helpful when you have many optional arguments that you only want to pass one value for. It would also be less error prone if arguments were added, removed, or reordered.
Obviously this would break compatibility. And to be honest it's probably undesirable to people with services taking only a couple parameters. So it would need to be either an option or a second method. I like the idea of an option for code size and simplicity but a second method would allow flexibility for those calling the client.
I'm working on a change myself but would like feedback before submitting a pull request. The output looks like this:
namespace API.Client {
'use strict';
interface IresourcesGetParams {
/** This is a required parameter */
requiredParam: string;
/** This is an optional parameter */
optionalParam?: string;
}
export class DefaultApi {
...
/**
* Retrieve a list of resources
* @param params Parameters.
*/
public resourcesGet (params: IresourcesGetParams, extraHttpRequestParams?: any) : ng.IHttpPromise<ResponseModel> {
- The interface and params argument wouldn't be present if there are no parameters.
- IresourcesGetParams should be IResourcesGetParams but I'm not sure the best way to go about that since I'm just grabbing the nickname.