Skip to content

Infer path parameters from scalar and tuple Path extractors#299

Open
hniksic wants to merge 1 commit into
tamasfe:mainfrom
hniksic:non-struct-paths
Open

Infer path parameters from scalar and tuple Path extractors#299
hniksic wants to merge 1 commit into
tamasfe:mainfrom
hniksic:non-struct-paths

Conversation

@hniksic

@hniksic hniksic commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Closes #113.

If a handler uses Path<(Uuid, u64)> or Path<Uuid> on a route with placeholders, aide currently emits an operation with no parameters at all. This caused issues with scalar and is rejected by strict validators. The workaround is to use a one-field struct, but that is noisy and duplicates information that's already in the route template (the name) and the extractor (type).

This makes aide infer parameters from the extractor type. E.g.:

  • Path<Uuid> on /users/{id} is interpreted as one id parameter, uuid-formatted string.
  • Path<(Uuid, u64)> on /users/{u}/posts/{p} -> two parameters in order, with the right types.
  • Path<SomeStruct> - unchanged.
  • A tuple whose length doesn't match the placeholder count is reported as an error.

Note that the x-aide-pending-path-params extension field is used only for internal book-keeping (to propagate path schemas from the extractor hook to route registration, where placeholder names become available) and doesn't end up in the emitted document.

This takes a different approach from #298, as this PR preserves type information (e.g. format: uuid on uuids).

`Path<Uuid>`, `Path<(Uuid, u64)>` and other non-struct `Path<T>`
extractors no longer produce operations with missing path parameters.
Each placeholder in the URL template now appears as a `Parameter::Path`
with a schema derived from the extractor type.
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.

Multiple path parameters from tuple are ignored

1 participant