-
-
Notifications
You must be signed in to change notification settings - Fork 533
Property without type should be declared as unknown #1039
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
Comments
It might be the same as #1031 and might be resolved by #1032 @duncanbeevers could you please confirm (or not) that this is the same issue? |
Yes, I can confirm that #1032 would resolve this issue. The type of I think your proposal that |
Thanks! |
I believe this is taken care of by the I also don’t want to debate this topic too much more, because I think no matter how you answer the question “what types should be generated when my schema doesn’t specify a type” isn’t a very productive conversation. No matter what the decision is, the fact is that your schema is lacking critical information needed to type it safely. And I’d rather err on the side of generating types to encourage you to fix it at the schema level, not the typegen level. |
I agree with this stance. Strict-by-default guides API designers towards better schemas. Importantly though, this tool is used to generate types for APIs outside of one's own control, so having controls for loosening the generated types is key. |
Exactly. Besides, I don't see why a discussion is necessary, since the spec is well-defined for these cases as I've demonstrated. Specs of this form - without Realistically, if this doesn't make it into project, I'm just going to have to complicate generation on my side as I'll need to use the Node API and specify a custom transform, and then implement this logic myself. |
@mitchell-merry Sorry—just for clarification, is the |
Oh, sorry—I understand now. Yes that doesn’t conflict and this should be fixed (rubber ducking works!). I’ll re-open your PR. |
Sure, I will do that tomorrow but I believe it's: a)
b)
c)
(as mentioned by @duncanbeevers in #1039 (comment))
No worries 😉 |
Description
openapi-typescript
6.1.1
18.12.2
Ubuntu 22.04.2
Reproduction
api.json
openapi-typescript
:type.ts
As you can see,
schemas.User.Info
is defined asRecord<string, never>
which is incorrect becauseInfo
might contain astring
,number
orboolean
and not necessarily anobject
.Expected result
Checklist
The text was updated successfully, but these errors were encountered: