Skip to content

routeParamNames

reference
1 min readUpdated

Kind: Function

Source: atloria-monorepo/libs/parser-core/src/openapi/path-parameters.ts

The variable segments of a route template, in URL order, deduped and stripped of framework decoration.

Deliberately dialect-agnostic, because one endpoint list mixes them: NestJS and Express write :id, OpenAPI/Spring/.NET write {id}, Laravel writes {id?} for optional and Rails {id:uuid} for constrained, and PHP string interpolation leaks {$endpoint} out of Route::match($verbs, "{$endpoint}{format?}"). All of them name the same thing: a segment the caller supplies.

For parsers only. They own the path text as well as the parameter list, so they can normalize both together; the spec-level backstop below cannot, and matches tokens verbatim instead.

Signature

ts
function routeParamNames(template: string): string[]

Parameters

NameType
templatestring

Returns: string[]

Was this page helpful?

Download as PDF