Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeScript fetch] doubling options #8067

Closed
ElfenLiedGH opened this issue Apr 24, 2018 · 3 comments
Closed

[TypeScript fetch] doubling options #8067

ElfenLiedGH opened this issue Apr 24, 2018 · 3 comments

Comments

@ElfenLiedGH
Copy link

ElfenLiedGH commented Apr 24, 2018

Description
Swagger-codegen version

2.3.1

Swagger declaration file content or url
  /Companies/change-stream:
    post:
      tags:
        - Company
      summary: Create a change stream.
      operationId: Company.createChangeStream__post_Companies_change-stream
      parameters:
        - name: options
          in: formData
          required: false
          type: string
          format: JSON
      responses:
        '200':
          description: Request was successful
          schema:
            type: file
      deprecated: false
    get:
      tags:
        - Company
      summary: Create a change stream.
      operationId: Company.createChangeStream__get_Companies_change-stream
      parameters:
        - name: options
          in: query
          required: false
          type: string
          format: JSON
      responses:
        '200':
          description: Request was successful
          schema:
            type: file
      deprecated: false
Command line used for generation
Steps to reproduce

https://editor.swagger.io/#

menu generate client->typescript fetch

Related issues/PRs
Suggest a fix/enhancement

generated code

    /**
     * 
     * @summary Create a change stream.
     * @param {string} [options] 
     * @param {*} [options] Override http request option.
     * @throws {RequiredError}
     */
    companyCreateChangeStreamPostCompaniesChangeStream(options?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
        const localVarFetchArgs = CompanyApiFetchParamCreator(configuration).companyCreateChangeStreamPostCompaniesChangeStream(options, options);
        return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
            return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
                if (response.status >= 200 && response.status < 300) {
                    return response.json();
                } else {
                    throw response;
                }
            });
        };
    },

swagger api's generated auto by loopback v3

@macjohnny
Copy link
Contributor

@ElfenLiedGH this is because by default you can pass a parameter options with a configuration object. A quick solution to your problem is to rename your options to e.g. streamOptions.
this issue is somehow similar to #7911, since we have naming conflicts with kind-of reserved keywords / names.

@ElfenLiedGH
Copy link
Author

@macjohnny it's autogenerated api from IBM strongloop, i can't change any format

@macjohnny
Copy link
Contributor

macjohnny commented Apr 26, 2018

@ElfenLiedGH would you like to give it a try and implement a fix similar to #7916 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants