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
  • Merge requests
  • !13189

[WIP] typescript-axios: support data/date-time to Date conversion

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/tibbe/typescript-axios-dates into master Aug 15, 2022
  • Overview 1
  • Commits 1
  • Pipelines 0
  • Changes 49

Created by: tibbe

WIP discussion starter.

I would like to judge the interest of adding an opt-in flag for having the typescript-axios generator support date/date-time conversion (and in the future perhaps full schema validation of the server response), like the typescript-fetch generator does today. The implementation would be (very) similar, with generated MyModelFromJSON functions and a isDate[Time]Type check to only enabled this if the user explicitly maps date/date-time to Date (string being the current default).

Is there interest in having this? It's quite a bit of work so I'd like to have some idea before going further. The existing commit only implements perhaps 20% of what's needed. I would probably need some guidance in what parts of typescript-fetch needs to be copied (e.g. typescript-fetch has a large ExtendedCodegenParameter class that I'm not sure is needed to just support e.g. isDateType).

Here's what I think are the remaining TODOs in this PR:

  • Add isDate[Time]Type to only enable this behavior if date/date-time are explicitly mapped to Date (default: off).
  • Add MyModelFromJSON calls in the right places, including dealing with arrays/maps.
  • See if anything can be shared between typescript-axios/typescript-fetch (I don't know if sharing between generators is encouraged).

When date/date-time formats are mapped to Date objects the Axios JSON payload is converted to a JavaScript Date object before it is returned.

Does not change the default behavior, as date/date-time is mapped to string by default in the typescript-axios generator.

Fixes #13188.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • x File the PR against the correct branch: master (6.1.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Technical Committee

@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/tibbe/typescript-axios-dates