openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[REQ] [angular-typescript] Support optional paramters for `useSingleRequestParameter=true`

Open angelaki opened this issue 1 year ago • 0 comments

I really like the generated code using useSingleRequestParameter=true but it would be great if the paramter would be optional if all the paramters' properties are.

E.g. if I have a

export interface GetValueRequestParams {
    s?: string;
}

right now it must be passed to the method:

    public getValue(requestParameters: GetValueRequestParams, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json', context?: HttpContext, transferCache?: boolean}): Observable<number>;
    public getValue(requestParameters: GetValueRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<number>>;
    public getValue(requestParameters: GetValueRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<number>>;
    public getValue(requestParameters: GetValueRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
        const s = requestParameters.s;

Could this case please be refactored to

    public getValue(requestParameters?: GetValueRequestParams, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json', context?: HttpContext, transferCache?: boolean}): Observable<number>;
    public getValue(requestParameters?: GetValueRequestParams, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<number>>;
    public getValue(requestParameters?: GetValueRequestParams, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<number>>;
    public getValue(requestParameters?: GetValueRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
        const s = requestParameters?.s;

No idea how to start here but if you support me a bit I would offer a PR :)

angelaki avatar Apr 22 '24 13:04 angelaki