Skip to content

#290 feat: OpenAPI schema overrides carried to generated structs - #291

Merged
RAprogramm merged 1 commit into
mainfrom
290
Jul 27, 2026
Merged

#290 feat: OpenAPI schema overrides carried to generated structs#291
RAprogramm merged 1 commit into
mainfrom
290

Conversation

@RAprogramm

Copy link
Copy Markdown
Owner

Closes #290

A JSONB column typed as serde_json::Value documents as a free-form object, and there was no way to say otherwise: #[schema(...)] is not a helper attribute of the derive, so writing it on an entity did not compile — and the generated DTOs would not have carried it anyway. The workaround was a hand-written duplicate of the generated struct existing only to hold the attribute.

The attribute is now accepted on a field and forwarded verbatim to every generated struct that derives utoipa::ToSchema: the create and response DTOs and the joined view. Whatever utoipa accepts works here, because nothing is parsed twice.

Two deliberate exclusions. With the api feature off nothing generated derives ToSchema, so the attribute is dropped rather than emitted onto a struct that cannot interpret it. Update DTOs never carry it: the macro rewrites their field types for PATCH semantics, so a declared value_type would contradict the type actually generated.

Covered by unit tests on the parser, a compile-pass case asserting all three generated structs implement ToSchema with an override in place, and documented in the README reference and the attribute page in all five wiki languages.

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@RAprogramm
RAprogramm merged commit 248c1da into main Jul 27, 2026
28 of 29 checks passed
@RAprogramm
RAprogramm deleted the 290 branch July 27, 2026 02:22
@RAprogramm RAprogramm mentioned this pull request Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No way to override the OpenAPI schema of a generated field

1 participant