Skip to content

Conversation

@Tuntii
Copy link
Owner

@Tuntii Tuntii commented Jan 29, 2026

This PR replaces the external utoipa dependency with a fully native OpenAPI 3.1 generator owned by RustAPI.

Key Changes:

  1. Native OpenAPI Model: Rewrote rustapi-openapi to define OpenAPI 3.1 structs (Spec, Operation, Schema, etc.) using BTreeMap to ensure deterministic output ordering.
  2. Schema Generation: Introduced RustApiSchema trait and implemented #[derive(Schema)] in rustapi-macros. This handles struct, enum, and primitive mapping to JSON Schema 2020-12.
  3. Runtime Integration: Updated rustapi-core extractors (Json, Query, Path) and response types (Created, ApiError) to implement RustApiSchema and populate the new OpenAPI spec directly.
  4. Swagger UI: Replaced the heavy utoipa-swagger-ui (and local asset bundling) with a simple HTML handler that loads Swagger UI from unpkg CDN.
  5. Cleanups: Removed utoipa from all Cargo.toml files.

Verification:

  • Added unit tests for schema derivation and spec generation.
  • Verified existing tests in rustapi-core pass with the new implementation.
  • Confirmed deterministic output structure.

PR created automatically by Jules for task 7665294518381585970 started by @Tuntii

- Replaced `utoipa` dependency with a native, lightweight OpenAPI 3.1 implementation in `rustapi-openapi`.
- Implemented `RustApiSchema` trait and `#[derive(Schema)]` macro for native JSON Schema generation.
- Updated `rustapi-core` to use the new schema system and `BTreeMap` for deterministic output.
- Replaced bundled Swagger UI with a CDN-based lightweight HTML handler.
- Added comprehensive design documentation in `docs/native_openapi.md`.
- Ensured backwards compatibility for `RustApi::auto()` and basic schema derivation.

Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 29, 2026 17:38
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Contributor

Copilot AI left a comment

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 replaces the external utoipa dependency with a fully native OpenAPI 3.1 generator for RustAPI. The change introduces a new schema trait (RustApiSchema) with a procedural macro (#[derive(Schema)]), replaces v31 OpenAPI types with a unified OpenApiSpec structure using BTreeMap for deterministic ordering, and switches from bundled Swagger UI assets to CDN-based loading.

Changes:

  • Removed utoipa dependency and replaced with native implementation
  • Unified OpenAPI 3.1 types (removed separate v31 module)
  • Implemented #[derive(Schema)] macro for schema generation
  • Switched Swagger UI from bundled assets to CDN

Reviewed changes

Copilot reviewed 22 out of 26 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
docs/native_openapi.md New architecture documentation for native OpenAPI implementation
crates/rustapi-openapi/src/v31/* Removed legacy v31 module (webhooks, tests, schema, spec, mod)
crates/rustapi-openapi/src/schema.rs New native schema implementation with RustApiSchema trait
crates/rustapi-openapi/src/spec.rs Unified OpenAPI spec using BTreeMap for deterministic output
crates/rustapi-openapi/src/swagger.rs Simplified Swagger UI using CDN instead of bundled assets
crates/rustapi-macros/src/derive_schema.rs New Schema derive macro implementation
crates/rustapi-core/src/*.rs Updated to use new RustApiSchema trait
Cargo.toml files Removed utoipa dependency, added rustapi-macros dependency

s.reference = Some(reference);
s
},
::rustapi_openapi::schema::SchemaRef::Inline(v) => {
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The Inline case at lines 70-73 discards the value v and creates an empty schema. This loses potentially important schema information. Consider parsing or converting the inline value, or at minimum add a comment explaining why it's intentionally discarded.

Suggested change
::rustapi_openapi::schema::SchemaRef::Inline(v) => {
::rustapi_openapi::schema::SchemaRef::Inline(v) => {
// Inline schemas are currently not converted into JsonSchema2020
// when building object properties. We intentionally discard `v`
// here and return an empty schema to preserve existing behavior.
let _ = v;

Copilot uses AI. Check for mistakes.
google-labs-jules bot and others added 13 commits January 29, 2026 18:00
- Replaced utoipa dependency with a native rustapi-openapi implementation.
- Implemented OpenApiSpec, Operation, Components using BTreeMap for deterministic output (OpenAPI 3.1).
- Implemented #[derive(Schema)] in rustapi-macros targeting RustApiSchema trait.
- Updated rustapi-core extractors and response modifiers to use the native schema system.
- Replaced embedded Swagger UI assets with a lightweight CDN-based HTML handler.
- Updated benchmarks and tests to reflect the changes.
- Fixed dependency issues in bench-server.

Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
- Fix `rustapi-openapi/src/spec.rs` linting issues (imports reordering).
- Update `rustapi-toon`, `rustapi-view`, and `rustapi-ws` to align with new `rustapi-openapi` types (BTreeMap, Option wrappers, missing fields).
- Initialize `MediaType` with `example: None`.
- Initialize `ResponseSpec` with `headers: BTreeMap::new()`.
- Wrap `schema` in `Some(...)`.
- Use `BTreeMap` instead of `HashMap` for content maps.

Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
Deleted all benchmark server crates, micro-benchmarks, and related scripts from the benches directory. Also removed benchmark server members from the Cargo workspace. This streamlines the repository by eliminating benchmarking infrastructure.
…extras

- Formatting: Fixed formatting in `crates/rustapi-view/src/view.rs` to match `cargo fmt`.
- Compilation:
    - Updated `crates/rustapi-extras/src/jwt/mod.rs` to match `rustapi-openapi` changes.
    - Used `BTreeMap` instead of `HashMap` for `ResponseSpec` content.
    - Initialized `MediaType` with missing `example: None`.
    - Wrapped schema value in `Some(...)`.
    - Initialized `ResponseSpec` with `headers: BTreeMap::new()`.

Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
- Deleted `benches/` directory.
- Removed benchmark crates from `Cargo.toml`.

Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
- Verified that previous fixes for `rustapi-toon`, `rustapi-view`, and `rustapi-ws` compile correctly with `cargo check --workspace --tests`.
- Verified formatting with `cargo fmt`.
- No new code changes were required as the previous submission successfully addressed the compilation errors. This submission is to trigger a fresh CI run on the corrected codebase.

Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
…ates

- Fix `clippy::large_enum_variant` in `rustapi-openapi`:
    - Box `JsonSchema2020` in `SchemaRef::Schema`.
    - Box `OAuthFlows` in `SecurityScheme::Oauth2`.
- Fix `clippy::new_without_default` in `rustapi-openapi`:
    - Implement `Default` for `SchemaCtx`.
- Update `rustapi-macros/src/derive_schema.rs` to dereference boxed `SchemaRef::Schema` variants.
- Update `rustapi-openapi/src/schema.rs` to dereference boxed schemas in `Vec`, `Option`, and `HashMap` implementations.
- Ensure `rustapi-extras` and `rustapi-view` are aligned with the `rustapi-openapi` changes (already addressed in previous steps, verified here).

Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
Replaces the utoipa dependency with a native OpenAPI 3.1 generator, introducing the RustApiSchema trait and #[derive(Schema)] macro for compile-time schema generation. Updates documentation, migration guides, and examples to reflect the new architecture, including support for JSON Schema 2020-12, deterministic output via BTreeMap, and CDN-based Swagger UI. All extractors and OpenApiSpec internals are refactored to use the new schema system, and a comprehensive migration guide is added.
Adjusted line breaks and indentation in spec.rs and native_openapi_demo.rs to enhance code clarity and maintain consistent formatting. No functional changes were made.
- Fixed formatting in `crates/rustapi-openapi/src/spec.rs` and `crates/rustapi-rs/examples/native_openapi_demo.rs` by running `cargo fmt --all`.
- Removed trailing whitespace in `crates/rustapi-macros/src/derive_schema.rs` that was causing `rustfmt` to fail.

Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
Copy link
Owner Author

@Tuntii Tuntii left a comment

Choose a reason for hiding this comment

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

LGTM

@Tuntii Tuntii merged commit fbfff75 into main Jan 30, 2026
7 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 30, 2026
…napi-7665294518381585970

Native OpenAPI 3.1 Generator fbfff75
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.

2 participants