-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
oas2ts generates duplicate type declaration #177
Comments
From what I see the issue seems to be in json-schema-to-typescript. Apparently the |
@simoneb I will try to send a PR to it |
There is already an open PR with the fix same I was going to make, but apparently there are some edge cases that would require quite few changes to it. I am closing this issue since it will be no longer occur on here once the bug in |
@pmusce Thanks for diagnosing this. I'll look at the PR and issue there and see if I can figure out a solution. Meanwhile, I've written a simple script to patch the files affected by it. |
Given the OpenAPI YAML below,
openapi-transformer-toolkit oas2ts
imports theABParams
type and generates type declaration for it inPath1Query.d.ts
andPath2Query.d.ts
. The duplicate declaration breaks lint rules against redeclaring types.Any ideas what might be causing this issue, why it things it needs to import and redeclare the type, or by what rationale importing and redeclaring the type is wise? (And if it is wise, how do I inject a lint ignore in the generated type without manually editing every time I generate?)
This example is a small reproduction. The real world case is a pair of routes that give different views of the same data. The routes require either
AParams
orBParams
or both (required enforced in business logic) and also acceptCommonOpts
(filter criteria). Path2 also acceptsExtraOpts
(sorting, pagination, etc.).Offending output (with callout comments added) for
Path1Query.d.ts
.Not sure if it helps understand why this is happening, but in the real world case,
ABParams
has a description and the description comment appears above the redeclaration.Thanks for any insight or solutions.
PS: If you're wondering, "Why not just use
ABParams
?" the answer is, docs (generated with@redocly/cli
). In the real world case I have titles on theAParams
,BParams
, andABParams
so API consumers can switch between param sets and see what's required for each.The text was updated successfully, but these errors were encountered: