-
-
Notifications
You must be signed in to change notification settings - Fork 473
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
Impossible 'body' field required in GET #1124
Comments
Edit: I didn’t know you could transfer issues! |
I am getting the same issue. However when I try to do something like:
I get a runtime error: Not sure how to circumvent that without disabling typechecking. |
Up |
|
Same issue here |
I think some of this may be fixed in If anyone is having issues in |
@drwpow I'm also having this exact issue on (every)
I can't share a full spec atm, but the types generated below map to the error above. If I had to bet, this seems like a generic "applies to all GET operations"-kinda issue export interface paths {
"/api/1.0/integrations/{provider}/{operationId}?connectionId={connectionId}": {
get: operations["providerOperationId"];
};
}
// ...
export interface operations {
providerOperationId: {
parameters: {
query: {
connectionId: components["parameters"]["connectionIdParam"];
};
path: {
provider: components["parameters"]["providerParam"];
operationId: components["parameters"]["operationIdParam"];
};
};
responses: {
200: {
content: {
"application/json": components["schemas"]["OperationOutcome"];
};
};
401: components["responses"]["Unauthorized"];
500: components["responses"]["Error"];
};
};
} (PS: Thank you for making this tool! Bug aside, what I've seen so far is awesome! 👏 ) |
I'm going to dig into this a bit as we are doing a big migration to openapi-typescript and a openapi-fetch-derived module that uses apollo, and I don't want to have to explain to PR reviewers why |
I took another look into this and I am still having a little trouble recreating it myself. I do believe all of you are having issues; I’m just not sure what the root problem is. @t1mmen Thanks for publishing all that, but I wasn’t able to reproduce the problem with just that alone; I have a feeling the bug is lurking in the rest of the generated types. I’ve published a version at |
I have a hunch that it may have to do with the spec, because when I tried this on Petstore it didn't seem to have the problem. |
@drwpow I tried openapi-fetch@test and it works for me (as in, no more complaints about body). I do notice that the second argument to |
That’s promising! That at least lets me know that’s on the right path to the root error.
Right—we’re tracking that with #1127. TypeScript struggled with making that 2nd param required when it truly needed to be, so currently there’s just a required object with optional keys. Issue is still tracking that. Would like to solve that before 1.0. |
Anyway, please give |
This issue is stale because it has been open for 90 days with no activity. If there is no activity in the next 7 days, the issue will be closed. |
Is this fixed? |
Description
I'm seeing an issue where generated typescript types result in some impossible types:
I am able to work around it by adding a field
body: "" as never
, which seems to be forcing TS into the right path.body: undefined
orbody: null
does not work either.Reproduction
I used the latest versions of openapi-fetch, openapi-typescript, and an internal OpenAPI spec with only GETs in it.
Something relevant in the generated code seems to be:
Expected result
I can work out the types in this scenario more easily.
Checklist
The text was updated successfully, but these errors were encountered: