feat: show schema names in request body details#45
Conversation
- Show schema reference name for $ref schemas - Show inline schema types for non-referenced schemas - Include request body description and required status - Improves visibility of what request body expects - Add test validating schema display with petstore example Previously, request bodies only showed media type without schema information
WalkthroughEnhanced OpenAPI RequestBody endpoint details rendering to display description and required status. Media type display now includes schema references or inline type information in parentheses for improved clarity. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
oas.go (1)
281-329: Request body rendering is correct; consider sharing schema formatting helperThe new request-body rendering logic in
formatEndpointDetailscorrectly:
- emits description and
Required: truewhen set, and- shows either
$ref-derived schema names or inlinetype/typesfor each media type, with stable alphabetical ordering.Two optional refinements:
- Factor the
(schema: …)/(type: …)construction into a small helper shared withformatRequestBodyDetails(and possiblyformatResponseDetails) to avoid duplication and to let component request bodies also show$refschema names.- When splitting the
$ref, consider guarding against an empty last segment to avoid emitting"(schema: )"for malformed refs.oas_test.go (1)
275-347: Good coverage of new request-body display; consider loosening description assertionThis test thoroughly exercises the new behavior (description, required flag, schema refs for all media types, and alphabetical ordering) and is well-structured.
One thing to consider: matching the request body description via the exact string
"Create a new pet in the store"tightly couples the test to the example spec’s wording. If that description is edited (while still being rendered correctly), the test will fail. You could instead:
- assert on the presence of
"Description:"plus a shorter, more stable substring, or- read the expected description from the parsed model and assert that it appears.
Everything else in the test looks solid for the intended behavior.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
oas.go(2 hunks)oas_test.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
oas_test.go (1)
model.go (2)
NewModel(212-229)Model(67-80)
|
Looks good, thank you! |
Overview
When viewing endpoint details, request bodies now display the schema name alongside the media type, making it easier to understand what data structure is expected without leaving the current view.
What Changed
Before:
After:
Implementation
$refpaths (e.g.,#/components/schemas/Pet→Pet)object,string)This keeps the interface clean and minimal > users see which schema is used in the Requests view, and can navigate to the Components tab for full schema details.
Testing
TestPetstoreRequestBodySchemaDisplayto validate schema reference extraction$refextensivelyExample
View the "Add a new pet to the store" endpoint in petstore-3.0.yaml to see the enhancement in action.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.