feat(openapi): document constrained route params
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
4 files changed
+56
-13
No files matched your search
+2
-2
@@ -1,6 +1,6 @@
|
||||
import type { RouteDef, MatchedRoute } from './types';
|
||||
|
||||
type CompiledSegment =
|
||||
export type CompiledSegment =
|
||||
| { kind: 'static'; value: string }
|
||||
| { kind: 'param'; name: string; constraint?: RegExp; constraintSource?: string }
|
||||
| { kind: 'catchAll'; name: string };
|
||||
@@ -147,7 +147,7 @@ export function compilePattern(pattern: string): CompiledPattern {
|
||||
if (pattern.includes('//')) throw new Error(`invalid route pattern '${pattern}': repeated slash`);
|
||||
|
||||
const normalized = pattern.length > 1 && pattern.endsWith('/') ? pattern.slice(0, -1) : pattern;
|
||||
const rawSegments = normalized.split('/').slice(1);
|
||||
const rawSegments = normalized === '/' ? [] : normalized.split('/').slice(1);
|
||||
const segments = compileSegments(pattern, rawSegments);
|
||||
const compiled: CompiledPattern = {
|
||||
source: pattern,
|
||||
|
||||
Reference in new issue
Block a user