Skip to content

feat: content types - #17

Merged
dotkas merged 2 commits into
mainfrom
feat/c4a-content-types
Jul 7, 2026
Merged

feat: content types#17
dotkas merged 2 commits into
mainfrom
feat/c4a-content-types

Conversation

@dotkas

@dotkas dotkas commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings July 7, 2026 11:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / BodyKind to 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, or String) 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.

Comment thread crates/oapi-codegen/src/lower/paths.rs
Comment thread crates/oapi-codegen/src/ir.rs Outdated
Comment thread crates/oapi-codegen/src/ir.rs Outdated
Comment thread crates/oapi-codegen/src/emit/axum.rs
@dotkas
dotkas merged commit 4380522 into main Jul 7, 2026
5 checks passed
@dotkas
dotkas deleted the feat/c4a-content-types branch July 7, 2026 12:11
@dotkas dotkas removed the released label Jul 16, 2026
@alchemaxinc alchemaxinc deleted a comment from alchemax-housekeeper Bot Jul 16, 2026
@alchemax-housekeeper

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.0.0-dev.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@alchemax-housekeeper

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants