OpenAPITools / OpenAPITools/openapi-generator
[BUG] Deprecated function used in JavaScript and TypeScript generators
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The current JavaScript and TypeScript generators use substr to get the date part (YYYY-MM-DD) from a full ISO-8601 date string, substr is deprecated and there is a substring function that is supported and that should be used instead.
Using deprecated functions might blocked by your build system.
Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
openapi-generator version
Tested 6.6.0 and Master - Not a regression
Steps to reproduce
Generate any spec file containing a date field, the code generated is:
httpParams = httpParams.append(key, (value as Date).toISOString().substr(0, 10));
Related issues/PRs
Found no issue or PR mentioning this
Suggest a fix
Draft PR: https://github.com/OpenAPITools/openapi-generator/pull/15937
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the JavaScript and TypeScript generator output for a date field, using the shown TypeScript line as the reproduction target. Check the generator templates for uses of the deprecated function, compare the generated output with the suggested replacement, and run the relevant generator tests; the linked draft PR may already contain the work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100