Skip to content

Add explicit export_app route and schema prefix - #140

Merged
owjs3901 merged 2 commits into
mainfrom
owjs3901/vespera-export-app-prefix
Aug 30, 2026
Merged

Add explicit export_app route and schema prefix#140
owjs3901 merged 2 commits into
mainfrom
owjs3901/vespera-export-app-prefix

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Summary

  • Add prefix to export_app! so plugin authors can declare a stable public URL namespace independent of their internal src/routes layout.
  • Apply the normalized prefix once to collected route metadata, keeping generated Axum paths and OpenAPI path keys identical.
  • Derive an OpenAPI component namespace from the same prefix, rename generated schemas, and rewrite every matching component reference.
  • Preserve explicit schema name attributes as global opt-outs.
  • Include the prefix in export cache identity and add the required minor changepack.

Rationale

Yeollin CMS loads independently authored plugin crates and merges their exported Vespera apps. Deriving public routes from Rust module layout makes moving a handler a public API change and leaves the intended plugin namespace implicit. It also cannot solve cross-crate component collisions: two plugins can each define a different Item, after which OpenAPI merging silently keeps only one schema and makes the other endpoint incorrect.

I chose prefix rather than base because the value is directly prepended to every exported route and route prefix is the clearest description at the call site. It also avoids suggesting that the value is an OpenAPI server or base URL.

Normalization is deterministic: a missing leading slash is added, trailing slashes are removed, and an empty string or root slash means no prefix. Whitespace, query or fragment syntax, empty path segments, and prefixes without an alphanumeric namespace are rejected with errors at the literal span.

For component names, the normalized path is Pascal-cased. A conventional leading /api segment is omitted when more specific segments follow, so /api/media-library yields the namespace MediaLibrary and Item becomes MediaLibraryItem. Explicit schema names such as SharedThing stay unnamespaced as deliberately global or shared DTOs. All component references are rewritten from the same rename map.

With no prefix, route paths, component names, and references remain unchanged.

Verification

  • cargo test --workspace
  • bun run lint (all-features clippy, no-default-features workspace clippy, rustfmt check, oxlint)
  • Focused coverage for prefix parsing, duplicates, normalization, parameter preservation, router/OpenAPI path identity, schema/reference namespacing, explicit-name opt-out, two-app collision-free merge, dangling-reference detection, and no-prefix byte identity.

@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown

Changepacks

vespera@0.3.1 → 0.4.0 - Cargo.toml

Minor

  • Add an explicit export_app! prefix option that namespaces routes, OpenAPI paths, and generated component schemas.

vespera_macro@0.3.1 - crates/vespera_macro/Cargo.toml

Maybe you forgot to write the following files to the latest version

vespera-bridge@0.3.1 → 0.4.0 - libs/vespera-bridge/build.gradle.kts

Minor

  • Add an explicit export_app! prefix option that namespaces routes, OpenAPI paths, and generated component schemas.

vespera-bridge-gradle-plugin@0.3.1 → 0.4.0 - libs/vespera-bridge-gradle-plugin/build.gradle.kts

Minor

  • Add an explicit export_app! prefix option that namespaces routes, OpenAPI paths, and generated component schemas.

@owjs3901
owjs3901 merged commit cf7150c into main Aug 30, 2026
9 checks passed
@owjs3901
owjs3901 deleted the owjs3901/vespera-export-app-prefix branch August 30, 2026 06:23
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.

1 participant