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

[TypeScript][Inversify] fix date path parameters

Open gualtierim opened this issue 7 years ago • 6 comments

PR checklist

  • [x] Read the contribution guidelines.
  • [x] Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • [x] Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • [x] Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Fix the date path parameters as in the PR #7479

@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny

gualtierim avatar Apr 20 '18 12:04 gualtierim

@gualtierim could you try it with the following code and post it here?

paths:
  /pet/{birthday}/foo/{id:.+}/{bla_bla}/bar:
    get:
      tags:
        - pet
      operationId: findPetsByStatusfoo
      produces:
        - application/xml
        - application/json
      parameters:
        - name: birthday
          in: path
          required: true
          type: string
          format: date-time
        - name: id:.+
          in: path
          required: true
          type: string
        - name: bla_bla
          in: path
          required: true
          type: string
          format: date-time
      responses:
        '200':
          schema:
            type: array
            items:
              $ref: '#/definitions/Pet'

macjohnny avatar Apr 20 '18 12:04 macjohnny

The result is:

public findPetsByStatusfoo(birthday: Date, id_: string, blaBla: Date, observe?: 'body', headers?: Headers): Observable<Array<Pet>>;
public findPetsByStatusfoo(birthday: Date, id_: string, blaBla: Date, observe?: 'response', headers?: Headers): Observable<HttpResponse<Array<Pet>>>;
public findPetsByStatusfoo(birthday: Date, id_: string, blaBla: Date, observe: any = 'body', headers: Headers = {}): Observable<any> {
        ....

        const response: Observable<HttpResponse<Array<Pet>>> = this.httpClient.get(`${this.basePath}/pet/${encodeURIComponent(String(birthday.toISOString()))}/foo/${encodeURIComponent(String(id_))}/${encodeURIComponent(String(blaBla.toISOString()))}/bar`, headers);
        if (observe == 'body') {
               return response.map(httpResponse => <Array<Pet>>(httpResponse.response));
        }
        return response;
}

gualtierim avatar Apr 27 '18 09:04 gualtierim

Excellent, so it seems to be correct

macjohnny avatar Apr 27 '18 10:04 macjohnny

Circleci failing seems to be unrelated:

[info] downloading https://jcenter.bintray.com/jline/jline/2.12.1/jline-2.12.1.jar ...
[warn] 	[FAILED     ] jline#jline;2.12.1!jline.jar: The HTTP response code for https://jcenter.bintray.com/jline/jline/2.12.1/jline-2.12.1.jar did not indicate a success. See log for more detail. (36ms)
[warn] 	[FAILED     ] jline#jline;2.12.1!jline.jar: The HTTP response code for https://jcenter.bintray.com/jline/jline/2.12.1/jline-2.12.1.jar did not indicate a success. See log for more detail. (36ms)
[warn] ==== jcenter: tried
[warn]   https://jcenter.bintray.com/jline/jline/2.12.1/jline-2.12.1.jar

TiFu avatar Apr 27 '18 16:04 TiFu

@TiFu I forked the master and i make only the changes described in the PR. In my opinion the error is unrelated. I didn't change dependencies or tests.

gualtierim avatar May 07 '18 08:05 gualtierim

In the README is not present any reference to the typescript-inversify. Maybe it can be useful. Thanks!

gualtierim avatar May 07 '18 08:05 gualtierim