Error about destructuring a property for missing request body -- on a GET
See original GitHub issueDescribe the bug I have an API specification that is valid according to swaggerhub.com, where I author it. I submitted an issue previously about a pattern that failed, since I was using ‘format’, instead of ‘pattern’
I have fixed that issue, so I no longer get a syntax error, but I’m getting an error when I call my api endpoints now.
The error is: Cannot destructure property 'content' of 'request.openapi.schema.requestBody' as it is null.
The problem is that I have no idea where this is coming from, but it only seems to happen on “GET” requests, where there is no body. As far as I know, that is proper formatting for openapi spec. Am I wrong?
To Reproduce Probably difficult. I might need some direction on where to debug the source code in order to narrow down the issue.
Actual behavior A call to certain API endpoints returns an error response with the exact output
Cannot destructure property 'content' of 'request.openapi.schema.requestBody' as it is null.
Expected behavior Well, if the API is valid (as indicated by swaggerhub.com), it should not raise an error. Also, requestBody should be empty or null in GET requests.
Examples and context I’m not sure, but a GET request with no defined request body I guess would be a good example.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
I figured out my issue, which may or may not be the cause of @kutenai 's problem. It seems that somewhere between 4.9.x and 4.12.x the value of
request.openapi.schema.requestBody
for GET requests with no body switched fromundefined
tonull
and I was checking forundefined
when destructuring but notnull
.I should mention that if I back up to 4.9.x, it works fine. So far, this fails in the same way on 4.10.x and 4.12.x (latest), so it is consistent.