swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

TypeScript code generation for OpenApi 3 has no post parameter (requestBody) in 3.0.0 branch

Open colorcube opened this issue 8 years ago • 6 comments

Description

the generated code has no post parameter

Swagger-codegen version

v 3

Swagger declaration file content or url

OpenApi 3 excerpt

paths:
  /login:
    post:
      requestBody:
        description: The email/password
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Login'

generated code excerpt

  public loginPost(observe?: 'body', reportProgress?: boolean): Observable<LoginUser>;
  public loginPost(observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<LoginUser>>;
  public loginPost(observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<LoginUser>>;
  public loginPost(observe: any = 'body', reportProgress: boolean = false): Observable<any> {

    let headers = this.defaultHeaders;

    // to determine the Accept header
    let httpHeaderAccepts: string[] = [
      'application/json'
    ];
    let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
    if (httpHeaderAcceptSelected != undefined) {
      headers = headers.set("Accept", httpHeaderAcceptSelected);
    }

    // to determine the Content-Type header
    let consumes: string[] = [
      'application/json'
    ];

    return this.httpClient.post<LoginUser>(`${this.basePath}/login`,
      null, // HERE is something missing
      {
        withCredentials: this.configuration.withCredentials,
        headers: headers,
        observe: observe,
        reportProgress: reportProgress
      }
    );
  }

Search for '// HERE is something missing'

Command line used for generation

java -jar swagger-codegen-cli-3.0.0-20180106.033640-15.jar generate -i api.yaml -l typescript-angular -o ./client

colorcube avatar Jan 07 '18 00:01 colorcube

any update on this?

MBcom avatar Dec 29 '18 16:12 MBcom

This needs a fix, the client is unusable right now...

artonge avatar Apr 02 '19 09:04 artonge

Yes me too, I need to run a postprocessing script to fix this among other issues. Any updates on this fix?

micaelboucard avatar Apr 03 '19 22:04 micaelboucard

Hey guys, going to check in order to add a PR

El mié., 3 abr. 2019 a las 17:05, Micky ([email protected]) escribió:

Yes me too, I need to run a postprocessing script to fix this among other issues. Any updates on this fix?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/swagger-api/swagger-codegen/issues/7331#issuecomment-479675790, or mute the thread https://github.com/notifications/unsubscribe-auth/ADHYMKY0rglsX1AN_rkmIWWuLfbzkGgXks5vdSWmgaJpZM4RVfO0 .

HugoMario avatar Apr 04 '19 01:04 HugoMario

Using this generator , the problem seems to be solved

image

RaduFurnea avatar Apr 11 '19 08:04 RaduFurnea

Indeed this bug makes this generator unusable

rosbly avatar Apr 06 '23 16:04 rosbly