question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What’s the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • 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]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
Xambeycommented, Feb 7, 2020

@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

1reaction
macjohnnycommented, Feb 7, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I convert string to datetime with format specification ...
Use new Date(dateString ) if your string is compatible with Date.parse() . If your format is incompatible (I think it is), you have...
Read more >
Convert dates stored as text to dates - Microsoft Support
Convert text dates with two-digit years by using Error Checking · Select the cell, cell range, or column that you want to reformat....
Read more >
Convert string or numeric time values into date format ...
Use this tool to specify a standard or custom time format for interpreting date and time values and converting those into a date...
Read more >
pandas.to_datetime — pandas 1.5.2 documentation
Convert argument to datetime. This function converts a scalar, array-like, Series or DataFrame /dict-like to a pandas datetime object. ... Specify a date...
Read more >
Convert Text and Numbers to Date and Date & Time
See the examples below, replacing field with the name of the original (unrecognized) field. Example formulas. If field is a text field… Format....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found