Skip to content

Add OpenAPI 3.2 support with webhooks and enhanced components - #6

Merged
gaspb merged 27 commits into
masterfrom
feat/sync-upstream
Dec 2, 2026
Merged

gaspb merged 27 commits into
masterfrom
feat/sync-upstream

Conversation

@gaspb

@gaspb gaspb commented Sep 28, 2026

Copy link
Copy Markdown
Member

Summary

This PR adds comprehensive support for OpenAPI 3.2 specification, including new features like webhooks, enhanced component definitions, and improved schema handling. It also introduces the ability to merge multiple OpenAPI documents and opt-in to OpenAPI 3.2 output.

Key Changes

OpenAPI 3.2 Support

  • Updated OpenAPI spec version from 3.1 to 3.2 in documentation
  • Added OpenApiVersion enum with Version31 (default) and Version32 variants
  • Added openapi(version = "3.2.0") derive attribute to opt-in to OpenAPI 3.2 output
  • Added new OpenAPI root-level fields:
    • webhooks: For describing incoming requests initiated by the API provider
    • json_schema_dialect: Default JSON Schema dialect for Schema Objects
    • $self (self_uri): URI identifying the OpenAPI document for resolving relative references

Enhanced Components

  • Expanded Components struct with new reusable component maps:
    • parameters: Reusable parameter definitions
    • examples: Reusable example objects
    • request_bodies: Reusable request body definitions
    • headers: Reusable header definitions
    • links: Reusable link definitions
    • callbacks: Reusable callback definitions
    • path_items: Reusable path item definitions
    • media_types: Reusable media type objects
  • Changed security_schemes to use RefOr<SecurityScheme> for better flexibility

OpenAPI Merging

  • Added merge(...) attribute to #[derive(OpenApi)] for combining multiple OpenAPI documents
  • Allows merging paths, components, and other metadata from referenced OpenAPI structs
  • Supports both nest(...) and merge(...) for different composition strategies

Security Scheme Improvements

  • Added deprecated field to MutualTls variant
  • Added deprecated field to ApiKeyValue struct
  • Enhanced documentation with examples

Path and Schema Enhancements

  • Added $ref support to PathItem for referencing other path items
  • Added Callback type alias for callback expressions mapping to path items
  • Added summary field to Response object
  • Added itemSchema support in Content for streaming media types (SSE, JSONL, etc.)

Code Generation Improvements

  • Added support for expression-based title and names attributes in derive macros
  • Improved parameter name handling with expression support
  • Enhanced schema derivation for flattened maps with recursive schema collection
  • Added support for deserialize_with attribute handling

New Example

  • Added openapi-3_2-sse example demonstrating Server-Sent Events documentation using OpenAPI 3.2's streaming media type support

Builder API Enhancements

  • Added OpenApiBuilder::openapi() method to set OpenAPI version
  • Added OpenApiBuilder::webhooks() method for webhook definitions
  • Added OpenApiBuilder::json_schema_dialect() method
  • Added OpenApiBuilder::self_uri() method

Notable Implementation Details

  • The default OpenAPI version remains 3.1.0 for backward compatibility
  • Webhook definitions use the same Paths structure as regular paths
  • The merge functionality allows selective override of fields (info, version, paths, etc.)
  • New component types are properly serialized with skip_serializing_if to keep output clean
  • All new fields are optional to maintain backward compatibility

https://claude.ai/code/session_01PvYxH9Xj7KQZCeSF2F81RT

siku2 and others added 27 commits June 28, 2026 19:44
fix: simplify utoipa-gen feature gates to fix jiff_0_2

Enabling the "jiff_0_2" feature on its own would not correctly enable
the more
elaborate is_primitive branch because it was mistakenly omitted from the
feature gate list.
Rather than merely fixing the feature gate list, this commit simplifies
the
logic to make such a mistake impossible in the future.
* fix: workaround time/cookie incompatibility

* Also fix examples
juhaku#1580)

* Fix stack overflow

* fix: emit vec![] instead of array literals to avoid large stack arrays

Wide structs/enums generated huge `[..]` array literals in ToSchema/IntoParams,
tripping clippy::large_stack_arrays and overflowing the stack. Make the Array
tokenizer emit vec![] and deny the lint so it doesn't regress again (juhaku#1454).

* chore: not really testing so just smoke test

---------

Co-authored-by: Rafał Mikrut <mikrutrafal@protonmail.com>
Co-authored-by: Jaye Park <jaye.park@helsing.ai>
* Add OpenAPI 3.2 support

* Fix OpenAPI 3.2 CI failures

* ci: re-trigger build after upstream time 0.3.48 yank

The 2026-06-12 CI run resolved time 0.3.48 (the repo intentionally does not
commit a root Cargo.lock, so CI takes the latest deps). time 0.3.48 shipped an
E0119 trait-coherence regression that broke the cookie crate, failing the
utoipa-gen and examples jobs (and cancelling utoipa via fail-fast).

time 0.3.48 has since been yanked and 0.3.49 published. This empty commit
re-runs CI to pick up the fixed resolution; verified locally that the full
utoipa-gen matrix and example compilation pass with time 0.3.49.

* Address review feedback on OpenAPI 3.2 support

- Keep `Version31` as the default OpenApiVersion; `Version32` is now opt-in
  (no deprecation). Reverts the default-output version back to 3.1.0 so the
  change is non-breaking until 3.2 tooling support is widespread.
- Add `OpenApiBuilder::openapi(..)` so 3.2 output can be opted into.
- Rename `self_url` field/builder to `self_uri` to match the spec wording.
- Simplify `OpenApiVersion` deserialize with slice `matches!` patterns.
- Drop redundant non-empty check when merging `additional_operations`.
- Use `RefOr::T(parameter.into())` instead of the double `.into().into()`.
- Tidy `HttpBuilder::deprecated` formatting.
- Revert the actix `#[utoipa::path]` doc examples from `rust,ignore` back to
  `rust` (they pass under the `actix_extras` feature CI runs).
* docs: add examples and changelog

* test: fix empty description being omitted

* chore: change parameters to refs
* add example for IntoParams with generic argument

* add automated test

* working example of generic params

it breaks everything else which is a bummer

* fix implementation with into_params

* update unit tests to pin behavior

* minor code cleaning

* remove example code

I assume a reviewer might call this superfluous. This code was useful for testing locally.

* shorten code

* fix warning

* add basic changelog
…ypes (juhaku#1592)

* feat(gen): support item_schema attribute for streaming/SSE response types

* chore: update sse example to use programmatic openapi 3.2 version mapping

* chore: use openapi version attribute

As juhaku#1591 is merged, I can remove `api.openapi = utoipa::openapi::OpenApiVersion::Version32;` from the example to replace with `#[openapi(version = "3.2.0", components(schemas(PetEvent)))]`.
* Recursively discover flattened fields in maps

This allows the discovered fields to appear in component.schemas without
having to explicitly list it as a workaround.

Fixes juhaku#1330

* Use assert_value

* Apply suggestion from @CommanderStorm

Co-authored-by: Frank Elsinga <frank@elsinga.de>

---------

Co-authored-by: Frank Elsinga <frank@elsinga.de>
Updated documentation comments to remove commented-out code.
Add the following entry in utoipa-gen/CHANGELOG.md

* Recursively discover flattened fields in maps for `#[serde(flatten)]`. (juhaku#1582)
The test was commented out as failing to compile. It was missing imports,
and the justfile did not enable `utoipa/auto_into_responses`, which gates
the `IntoResponses` impl for `Result<T, E>`.
…uhaku#1619)

This commit removes support for expression style ignore attribute from `ToSchema` and `IntoParams` macro. This is to fix issue where ignore sometimes did not ignore values, because it was evaluated in runtime and function reference ignore can be evaluated only during runtime but we need to evaluate this at build time thus removing the possibility to define function reference as ignore attribute value.


 ## Breaking

Following syntax demonstrates what was allowed before, but will be not available in new version 6.
```rust
// before allowed

fn ignore_always() -> bool {
  true
}

#[derive(ToSchema)]
struct Value {
  #[schema(ignore = ignore_always)]
  field: String
}
```
This bug has been around since `utoipa-gen 5.1.3` where the
`#[schema(min_properties=...)]` gets generated as `max_properties`
attribute.

Closes juhaku#1622
Utoipa-swagger-ui build failed to build with `cache` feature on because
sha2 crate had updated its `generic-array` to `hybrid-array` dependency
breaking the existing implementation hex formatting. More details here:
RustCrypto/hybrid-array#201
Fix unsigned integers know format serialization. They used falsely `kebab-case` instead of `lowercase`. 

Now type like `UInt16` will render `uint16` instead of `u-int16`.
---------

Co-authored-by: Juha Kukkonen <juha7kukkonen@gmail.com>
Implements rust expression support for `names` and `title` attributes:
```rust
    const STRUCT_TITLE: &str = "Post Title";

    let schema = api_doc! {
        #[schema(title = STRUCT_TITLE)]
        struct Post {
            id: i64,
            description: String,
        }
    };
    const NEW_NAME: &str = "renamed_field";

    #[derive(IntoParams)]
    #[into_params(parameter_in = Path, names(NEW_NAME))]
    struct Filter(
        #[allow(unused)]
        (),
    );
```

---------

Co-authored-by: Juha Kukkonen <juha7kukkonen@gmail.com>
…u#1625)

Add missing snapshots for `utoipa-gen` test using newly supported expression in title and name.

```rust
const NEW_NAME: &str = "renamed_field";

#[derive(IntoParams)]
#[into_params(parameter_in = Path, names(NEW_NAME))]
struct Filter(());
```

---------

Co-authored-by: juhaku <26358664+juhaku@users.noreply.github.com>
Serde only treats a missing Option field as None when the field has no deserialize_with or with attribute. With one of those and no default, a missing field is an error, so ToSchema and IntoParams should list the field as required. It stays nullable.
Add support  for `merge` in `OpenApi` derive

Keep nest and merge as separate derive attributes, but parse their common
api and tags arguments through OpenApiReference. List merge in the
unexpected-attribute diagnostic and cover merge precedence in tests.

---------

Co-authored-by: Martin Moreira de Jesus <martin.moreira-de-jesus@protonmail.com>
Brings in 26 upstream commits (OpenAPI 3.2 support, syn 3, generic
IntoParams, `merge` in OpenApi derive, expr titles/names, several
schema fixes) on top of the fork's tagged_discriminator and IntoParams
flatten features.

- keep meteroid-* package names, bump to upstream versions
  (utoipa/gen 6.0.0, config 0.1.3, axum 0.3.0, scalar 0.4.0)
- combine IntoParams flatten support with upstream generic schemas
- adjust new upstream snapshot for the fork's crate description
- update RELEASING.md versions
@gaspb
gaspb merged commit 7d55b91 into master Dec 2, 2026
2 of 24 checks passed
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.