forked from block65/openapi-constructs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
16 lines (14 loc) · 628 Bytes
/
types.ts
File metadata and controls
16 lines (14 loc) · 628 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import type { Parameter } from './parameter.ts';
/* eslint-disable @typescript-eslint/no-unused-vars */
export type ExtractRouteParams<T> = string extends T
? Record<string, string>
: T extends `${infer _Start}{${infer Param}}/${infer Rest}`
? { [k in Param | keyof ExtractRouteParams<Rest>]: string }
: T extends `${infer _Start}{${infer Param}}`
? { [k in Param]: string }
: Record<string, never>;
export type ValidParameter<TPath extends string> =
| Parameter<keyof ExtractRouteParams<TPath>, 'path'>
| Parameter<string, 'query'>
| Parameter<string, 'header'>
| Parameter<string, 'cookie'>;