feat: content types - #17
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands the server generator’s request/response body handling from JSON-only to a single selected content type per operation/response (JSON, form, or text), and documents the supported/unsupported behaviors.
Changes:
- Add
ir::Body/BodyKindto carry both the Rust type and selected wire-format for request/response bodies. - Update lowering to select a body content type by priority (JSON > form > text) and to error on unsupported-only request bodies.
- Update axum emission to use the appropriate extractor/response wrapper (
axum::Json,axum::Form, orString) and add new fixtures/snapshots for text/form/json-charset cases.
Reviewed changes
Copilot reviewed 12 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents content-type selection behavior and new unsupported cases. |
| crates/oapi-codegen/src/ir.rs | Introduces Body/BodyKind and threads them through operation/response IR. |
| crates/oapi-codegen/src/lower/paths.rs | Implements content-type selection and lowers request/response bodies into Body. |
| crates/oapi-codegen/src/emit/axum.rs | Emits axum extractors/response terms based on BodyKind. |
| crates/oapi-codegen/tests/coverage.rs | Registers new supported/unsupported server fixtures for coverage enforcement. |
| crates/oapi-codegen/tests/generated_compiles.rs | Includes new generated snapshots and adds compile-time wiring tests for new fixtures. |
| crates/oapi-codegen/tests/generated/server_text_body.rs | Snapshot output for text/plain request/response bodies. |
| crates/oapi-codegen/tests/generated/server_form_body.rs | Snapshot output for application/x-www-form-urlencoded request bodies. |
| crates/oapi-codegen/tests/generated/server_json_charset.rs | Snapshot output for JSON request bodies with ; charset=utf-8 media type. |
| crates/oapi-codegen/tests/fixtures/server_text_body.yaml | New fixture for text/plain body handling. |
| crates/oapi-codegen/tests/fixtures/server_form_body.yaml | New fixture for form body handling. |
| crates/oapi-codegen/tests/fixtures/server_json_charset.yaml | New fixture for JSON media-type parameter handling. |
| crates/oapi-codegen/tests/fixtures/server_unsupported_only_binary_body.yaml | New negative fixture for unsupported-only request body types. |
| crates/oapi-codegen/tests/fixtures/server_unsupported_text_non_string_body.yaml | New negative fixture for non-string text/plain schema. |
| crates/oapi-codegen/tests/fixtures/server_unsupported_form_scalar_body.yaml | New negative fixture for non-$ref form schema. |
Contributor
|
🎉 This PR is included in version 1.0.0-dev.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Contributor
|
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.