fix: include body schema in OpenAPI docs when parse is 'none'#324
fix: include body schema in OpenAPI docs when parse is 'none'#324kaigritun wants to merge 1 commit into
Conversation
When using `parse: 'none'` to preserve raw request bodies, the body schema was being omitted from generated OpenAPI documentation because the 'none' case was not handled in the content type switch statement. This fix adds a case for 'none' that includes all common content types (application/json, application/x-www-form-urlencoded, multipart/form-data, text/plain) since the raw body could be any format. Fixes #1720
WalkthroughThe PR adds support for the 'none' parse option in OpenAPI schema generation. When a request body specifies Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hey! We're hitting the same root cause with Would it make sense to also handle |
Summary
Fixes #1720
When using
parse: 'none'to preserve raw request bodies, the body schema was being omitted from generated OpenAPI documentation.Problem
The issue was in the content type switch statement in
src/openapi.ts. Whenparse: 'none'is set:hooks.parseexists (the array contains the 'none' parser)if (hooks.parse)branchparser.fn === 'none'doesn't match any case in the switchcontentremains an empty object{}operation.requestBody.contentis set to emptySolution
Added a
case 'none':that includes all common content types (application/json, application/x-www-form-urlencoded, multipart/form-data, text/plain) since the raw body could be any format.Testing
Added test case that verifies body schema is included when
parse: 'none'is set.Summary by CodeRabbit
New Features
Tests