Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6497
Closed
Open
Issue created May 30, 2020 by Administrator@rootContributor

[BUG] [Javascript] Modify parseDate in ApiClient to support epoch time in addition to ISO-8601

Created by: tray2100

Description

The APIs from the Javascript client generated seem to receive Date values in epoch millis instead of ISO-8601. However, it seems that the APIs (specifically the constructFromObject function) doesn't handle converting from epoch millis and results in 'Invalid Date'. This is happening because the long value is being converted to a string before being passed to the Date object constructor.

The solution here would be to just check if the incoming object type and if it's numeric then just pass it on to Date without wrapping it in a string first.

openapi-generator version

4.3.1

Suggest a fix

Modify this portion of the mustache file to look like this:

  exports.parseDate = function(str) {
    if (!isNaN(str)) {
      return new Date(+str);
    }
    return new Date(str.replace(/T/i, ' '));
  };
Assignee
Assign to
Time tracking