Openapi-generator: [BUG][TYPESCRIPT-RXJS] Format Date is converted to Date-Time

Created on 10 Dec 2019  路  10Comments  路  Source: OpenAPITools/openapi-generator

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator (example)?
  • [x] What's the version of OpenAPI Generator used?
  • [x] Have you search for related issues/PRs?
  • [x] What's the actual output vs expected output?
Description

Hey,

when generating a parameter with the format 'date', it is falsely converted to 'date-time'. So in my case 'dateFrom' contains a time (e.g. '2019-12-10T17:56:56.999Z'), but should look like this: '2019-12-10'.

openapi-generator version

4.2.2

OpenAPI declaration file content or url
...
- name: date_from
          in: query
          description: >-
            Date parameter to search for ... (format\: \"yyyy-MM-dd\")
          required: false
          schema:
            type: string
            format: date
...
Command line used for generation

openapi-generator generate -i assets/api.yaml -g typescript-rxjs -o src/lib

Steps to reproduce

  • Generate the api
  • View the dateFrom parameter
Related issues/PRs
Suggest a fix

As in the typescript-fetch generator, write instead of .toISOString():

.toISOString().substr(0,10) or
.toISOString().split('T')[0]

TypeScript Bug

Most helpful comment

@guidoknoll you can take the package from my forks, there this and some other problems are fixed https://github.com/Xambey/openapi-generator-cli and https://github.com/Xambey/openapi-generator
openapi-generator-cli.zip

All 10 comments

馃憤 Thanks for opening this issue!
馃彿 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

  • very important issue

Related with: #4623

@denyo could you take a look at this issue? This seems to be easy fixable. I'd appreciate it a lot!

@guidoknoll would you like to implement a fix?

Yeah, i could do that too. But I've never committed to an open source project like this before but I'll try!

as a starting point:
adjust the template in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript-rxjs/apis.mustache
then run mvn clean package
and re-generate the samples by running https://github.com/OpenAPITools/openapi-generator/blob/master/bin/typescript-rxjs-petstore-all.sh

finally commit the changed templates and the generated samples.

@guidoknoll you can take the package from my forks, there this and some other problems are fixed https://github.com/Xambey/openapi-generator-cli and https://github.com/Xambey/openapi-generator
openapi-generator-cli.zip

The fix was quite easy and no samples changed. @macjohnny to which branch should i commit my changes or can i create my own?

You can fork the repo, create your own branch and then file a PR

Was this page helpful?
0 / 5 - 0 ratings