[typescript-fetch] centralise date handling, add dateLibrary
Merged
WI
4mo ago+3832+3832+0123456789012345678901234567890123456789-134-134-012345678901234567890123456789
based on https://github.com/OpenAPITools/openapi-generator/pull/24637 with updated samples.
all TS tests passed.
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
(For Windows users, please run the script in WSL)./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
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*.
IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed. - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Summary by cubic
Centralizes date handling for typescript-fetch and adds a dateLibrary option to choose Date (default) or string. Fixes format: date bugs (incorrect form param serialization and UTC day shifts) by using the local calendar for date and UTC for date-time.
- Runtime: all date parsing/serialization now uses
parseDate,parseDateTime,serializeDate, andserializeDateTimeinruntime.ts;querystringand path/query/form params route through these. - Generator: new
additionalProperties.dateLibraryoption (date|string);withoutRuntimeChecksimpliesstring. Docs updated. - Templates: models and
oneOfguards align with helpers; date imports only when needed viax-hasDateVars. ES6-safe code; preserves years 0000–0099 and rejects invalid dates. - Tests/samples: added a fixture covering all date locations and two sample builds (
dateandstring).
Migration
- If your client expects string dates, set
-p dateLibrary=string(ordateLibrary: stringin config). Regenerate and update types accordingly. - If you relied on
withoutRuntimeChecksfor string dates, no change; to getDate, disable that flag and/or set-p dateLibrary=date.