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 toDate
(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
./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