@furystack/rest 8.0.42 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/README.md +37 -1
- package/esm/api-endpoint-schema.d.ts +47 -2
- package/esm/api-endpoint-schema.d.ts.map +1 -1
- package/esm/index.d.ts +4 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +4 -1
- package/esm/index.js.map +1 -1
- package/esm/openapi-document.d.ts +303 -0
- package/esm/openapi-document.d.ts.map +1 -0
- package/esm/openapi-document.js +2 -0
- package/esm/openapi-document.js.map +1 -0
- package/esm/openapi-resolve-refs.d.ts +20 -0
- package/esm/openapi-resolve-refs.d.ts.map +1 -0
- package/esm/openapi-resolve-refs.js +68 -0
- package/esm/openapi-resolve-refs.js.map +1 -0
- package/esm/openapi-resolve-refs.spec.d.ts +2 -0
- package/esm/openapi-resolve-refs.spec.d.ts.map +1 -0
- package/esm/openapi-resolve-refs.spec.js +294 -0
- package/esm/openapi-resolve-refs.spec.js.map +1 -0
- package/esm/openapi-to-rest-api.d.ts +197 -0
- package/esm/openapi-to-rest-api.d.ts.map +1 -0
- package/esm/openapi-to-rest-api.js +2 -0
- package/esm/openapi-to-rest-api.js.map +1 -0
- package/esm/openapi-to-rest-api.spec.d.ts +2 -0
- package/esm/openapi-to-rest-api.spec.d.ts.map +1 -0
- package/esm/openapi-to-rest-api.spec.js +665 -0
- package/esm/openapi-to-rest-api.spec.js.map +1 -0
- package/esm/openapi-to-schema.d.ts +24 -0
- package/esm/openapi-to-schema.d.ts.map +1 -0
- package/esm/openapi-to-schema.js +145 -0
- package/esm/openapi-to-schema.js.map +1 -0
- package/esm/openapi-to-schema.spec.d.ts +2 -0
- package/esm/openapi-to-schema.spec.d.ts.map +1 -0
- package/esm/openapi-to-schema.spec.js +610 -0
- package/esm/openapi-to-schema.spec.js.map +1 -0
- package/esm/rest-api.d.ts +21 -4
- package/esm/rest-api.d.ts.map +1 -1
- package/esm/swagger-document.d.ts +2 -195
- package/esm/swagger-document.d.ts.map +1 -1
- package/esm/swagger-document.js +2 -1
- package/esm/swagger-document.js.map +1 -1
- package/package.json +3 -3
- package/src/api-endpoint-schema.ts +56 -3
- package/src/index.ts +4 -1
- package/src/openapi-document.ts +328 -0
- package/src/openapi-resolve-refs.spec.ts +324 -0
- package/src/openapi-resolve-refs.ts +71 -0
- package/src/openapi-to-rest-api.spec.ts +823 -0
- package/src/openapi-to-rest-api.ts +263 -0
- package/src/openapi-to-schema.spec.ts +707 -0
- package/src/openapi-to-schema.ts +163 -0
- package/src/rest-api.ts +26 -5
- package/src/swagger-document.ts +2 -220
package/esm/rest-api.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { ApiEndpointSchema } from './api-endpoint-schema.js';
|
|
2
2
|
import type { Method } from './methods.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { OpenApiDocument } from './openapi-document.js';
|
|
4
|
+
/**
|
|
5
|
+
* Defines the shape of a REST API as a mapping of HTTP methods to path-endpoint pairs.
|
|
6
|
+
* Each endpoint describes its result type and optionally its URL parameters, query parameters,
|
|
7
|
+
* request body, headers, and metadata like tags/deprecated/summary/description.
|
|
8
|
+
*
|
|
9
|
+
* This type is the shared contract between `@furystack/rest-service` (server) and
|
|
10
|
+
* `@furystack/rest-client-fetch` (client). It can also be derived from an OpenAPI document
|
|
11
|
+
* using `OpenApiToRestApi<T>`.
|
|
12
|
+
*/
|
|
4
13
|
export type RestApi = {
|
|
5
14
|
[TMethod in Method]?: {
|
|
6
15
|
[TUrl: string]: {
|
|
@@ -9,12 +18,16 @@ export type RestApi = {
|
|
|
9
18
|
query?: unknown;
|
|
10
19
|
body?: unknown;
|
|
11
20
|
headers?: unknown;
|
|
21
|
+
tags?: string[];
|
|
22
|
+
deprecated?: boolean;
|
|
23
|
+
summary?: string;
|
|
24
|
+
description?: string;
|
|
12
25
|
};
|
|
13
26
|
};
|
|
14
27
|
};
|
|
15
28
|
/**
|
|
16
|
-
* Represents an API with a GET action to retrieve its schema.
|
|
17
|
-
* This type extends the base RestApi type to include
|
|
29
|
+
* Represents an API with a GET action to retrieve its schema and OpenAPI document.
|
|
30
|
+
* This type extends the base RestApi type to include specific GET endpoints for schema and OpenAPI retrieval.
|
|
18
31
|
*/
|
|
19
32
|
export type WithSchemaAction<T extends RestApi> = T & {
|
|
20
33
|
GET: {
|
|
@@ -24,8 +37,12 @@ export type WithSchemaAction<T extends RestApi> = T & {
|
|
|
24
37
|
accept: 'application/schema+json';
|
|
25
38
|
};
|
|
26
39
|
};
|
|
40
|
+
'/openapi.json': {
|
|
41
|
+
result: OpenApiDocument;
|
|
42
|
+
};
|
|
43
|
+
/** @deprecated Use `/openapi.json` instead. This endpoint will be removed in a future major version. */
|
|
27
44
|
'/swagger.json': {
|
|
28
|
-
result:
|
|
45
|
+
result: OpenApiDocument;
|
|
29
46
|
};
|
|
30
47
|
};
|
|
31
48
|
};
|
package/esm/rest-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-api.d.ts","sourceRoot":"","sources":["../src/rest-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,MAAM,MAAM,OAAO,GAAG;KACnB,OAAO,IAAI,MAAM,CAAC,CAAC,EAAE;QACpB,CAAC,IAAI,EAAE,MAAM,GAAG;
|
|
1
|
+
{"version":3,"file":"rest-api.d.ts","sourceRoot":"","sources":["../src/rest-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D;;;;;;;;GAQG;AACH,MAAM,MAAM,OAAO,GAAG;KACnB,OAAO,IAAI,MAAM,CAAC,CAAC,EAAE;QACpB,CAAC,IAAI,EAAE,MAAM,GAAG;YACd,MAAM,EAAE,OAAO,CAAA;YACf,GAAG,CAAC,EAAE,OAAO,CAAA;YACb,KAAK,CAAC,EAAE,OAAO,CAAA;YACf,IAAI,CAAC,EAAE,OAAO,CAAA;YACd,OAAO,CAAC,EAAE,OAAO,CAAA;YACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;YACf,UAAU,CAAC,EAAE,OAAO,CAAA;YACpB,OAAO,CAAC,EAAE,MAAM,CAAA;YAChB,WAAW,CAAC,EAAE,MAAM,CAAA;SACrB,CAAA;KACF;CACF,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,GAAG;IACpD,GAAG,EAAE;QACH,SAAS,EAAE;YAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;YAAC,OAAO,EAAE;gBAAE,MAAM,EAAE,yBAAyB,CAAA;aAAE,CAAA;SAAE,CAAA;QAC3F,eAAe,EAAE;YAAE,MAAM,EAAE,eAAe,CAAA;SAAE,CAAA;QAC5C,wGAAwG;QACxG,eAAe,EAAE;YAAE,MAAM,EAAE,eAAe,CAAA;SAAE,CAAA;KAC7C,CAAA;CACF,CAAA"}
|
|
@@ -1,196 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
info: InfoObject;
|
|
4
|
-
jsonSchemaDialect?: string;
|
|
5
|
-
externalDocs?: ExternalDocumentationObject;
|
|
6
|
-
servers?: ServerObject[];
|
|
7
|
-
tags?: TagObject[];
|
|
8
|
-
security?: SecurityRequirementObject[];
|
|
9
|
-
paths?: Record<string, PathItem>;
|
|
10
|
-
webhooks?: Record<string, PathItem>;
|
|
11
|
-
components?: ComponentsObject;
|
|
12
|
-
[key: `x-${string}`]: unknown;
|
|
13
|
-
};
|
|
14
|
-
export type InfoObject = {
|
|
15
|
-
title: string;
|
|
16
|
-
version: string;
|
|
17
|
-
description?: string;
|
|
18
|
-
summary?: string;
|
|
19
|
-
termsOfService?: string;
|
|
20
|
-
contact?: ContactObject;
|
|
21
|
-
license?: LicenseObject;
|
|
22
|
-
[key: `x-${string}`]: unknown;
|
|
23
|
-
};
|
|
24
|
-
export type ContactObject = {
|
|
25
|
-
name?: string;
|
|
26
|
-
url?: string;
|
|
27
|
-
email?: string;
|
|
28
|
-
[key: `x-${string}`]: unknown;
|
|
29
|
-
};
|
|
30
|
-
export type LicenseObject = {
|
|
31
|
-
name: string;
|
|
32
|
-
identifier?: string;
|
|
33
|
-
url?: string;
|
|
34
|
-
[key: `x-${string}`]: unknown;
|
|
35
|
-
};
|
|
36
|
-
export type ExternalDocumentationObject = {
|
|
37
|
-
url: string;
|
|
38
|
-
description?: string;
|
|
39
|
-
[key: `x-${string}`]: unknown;
|
|
40
|
-
};
|
|
41
|
-
export type ServerObject = {
|
|
42
|
-
url: string;
|
|
43
|
-
description?: string;
|
|
44
|
-
variables?: Record<string, ServerVariableObject>;
|
|
45
|
-
[key: `x-${string}`]: unknown;
|
|
46
|
-
};
|
|
47
|
-
export type ServerVariableObject = {
|
|
48
|
-
default: string;
|
|
49
|
-
description?: string;
|
|
50
|
-
enum?: string[];
|
|
51
|
-
[key: `x-${string}`]: unknown;
|
|
52
|
-
};
|
|
53
|
-
export type TagObject = {
|
|
54
|
-
name: string;
|
|
55
|
-
description?: string;
|
|
56
|
-
externalDocs?: ExternalDocumentationObject;
|
|
57
|
-
[key: `x-${string}`]: unknown;
|
|
58
|
-
};
|
|
59
|
-
export type SecurityRequirementObject = Record<string, string[]>;
|
|
60
|
-
export type ComponentsObject = {
|
|
61
|
-
schemas?: Record<string, object | boolean>;
|
|
62
|
-
responses?: Record<string, ResponseObject | ReferenceObject>;
|
|
63
|
-
parameters?: Record<string, ParameterObject | ReferenceObject>;
|
|
64
|
-
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
65
|
-
requestBodies?: Record<string, RequestBodyObject | ReferenceObject>;
|
|
66
|
-
headers?: Record<string, HeaderObject | ReferenceObject>;
|
|
67
|
-
securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;
|
|
68
|
-
links?: Record<string, LinkObject | ReferenceObject>;
|
|
69
|
-
callbacks?: Record<string, CallbackObject | ReferenceObject>;
|
|
70
|
-
pathItems?: Record<string, PathItem | ReferenceObject>;
|
|
71
|
-
[key: `x-${string}`]: unknown;
|
|
72
|
-
};
|
|
73
|
-
export type ReferenceObject = {
|
|
74
|
-
$ref: string;
|
|
75
|
-
description?: string;
|
|
76
|
-
summary?: string;
|
|
77
|
-
};
|
|
78
|
-
export type PathItem = {
|
|
79
|
-
summary?: string;
|
|
80
|
-
description?: string;
|
|
81
|
-
get?: Operation;
|
|
82
|
-
put?: Operation;
|
|
83
|
-
post?: Operation;
|
|
84
|
-
delete?: Operation;
|
|
85
|
-
options?: Operation;
|
|
86
|
-
head?: Operation;
|
|
87
|
-
patch?: Operation;
|
|
88
|
-
trace?: Operation;
|
|
89
|
-
servers?: ServerObject[];
|
|
90
|
-
parameters?: Array<ParameterObject | ReferenceObject>;
|
|
91
|
-
[key: `x-${string}`]: unknown;
|
|
92
|
-
};
|
|
93
|
-
export type Operation = {
|
|
94
|
-
tags?: string[];
|
|
95
|
-
summary?: string;
|
|
96
|
-
description?: string;
|
|
97
|
-
externalDocs?: ExternalDocumentationObject;
|
|
98
|
-
operationId?: string;
|
|
99
|
-
parameters?: Array<ParameterObject | ReferenceObject>;
|
|
100
|
-
requestBody?: RequestBodyObject | ReferenceObject;
|
|
101
|
-
responses: ResponsesObject;
|
|
102
|
-
callbacks?: Record<string, CallbackObject | ReferenceObject>;
|
|
103
|
-
deprecated?: boolean;
|
|
104
|
-
security?: SecurityRequirementObject[];
|
|
105
|
-
servers?: ServerObject[];
|
|
106
|
-
[key: `x-${string}`]: unknown;
|
|
107
|
-
};
|
|
108
|
-
export type ParameterObject = {
|
|
109
|
-
name: string;
|
|
110
|
-
in: 'query' | 'header' | 'path' | 'cookie';
|
|
111
|
-
description?: string;
|
|
112
|
-
required?: boolean;
|
|
113
|
-
deprecated?: boolean;
|
|
114
|
-
allowEmptyValue?: boolean;
|
|
115
|
-
style?: string;
|
|
116
|
-
explode?: boolean;
|
|
117
|
-
allowReserved?: boolean;
|
|
118
|
-
schema?: object | boolean;
|
|
119
|
-
example?: unknown;
|
|
120
|
-
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
121
|
-
content?: Record<string, MediaTypeObject>;
|
|
122
|
-
[key: `x-${string}`]: unknown;
|
|
123
|
-
};
|
|
124
|
-
export type RequestBodyObject = {
|
|
125
|
-
description?: string;
|
|
126
|
-
content: Record<string, MediaTypeObject>;
|
|
127
|
-
required?: boolean;
|
|
128
|
-
[key: `x-${string}`]: unknown;
|
|
129
|
-
};
|
|
130
|
-
export type MediaTypeObject = {
|
|
131
|
-
schema?: object | boolean;
|
|
132
|
-
example?: unknown;
|
|
133
|
-
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
134
|
-
encoding?: Record<string, EncodingObject>;
|
|
135
|
-
[key: `x-${string}`]: unknown;
|
|
136
|
-
};
|
|
137
|
-
export type EncodingObject = {
|
|
138
|
-
contentType?: string;
|
|
139
|
-
headers?: Record<string, HeaderObject | ReferenceObject>;
|
|
140
|
-
style?: string;
|
|
141
|
-
explode?: boolean;
|
|
142
|
-
allowReserved?: boolean;
|
|
143
|
-
[key: `x-${string}`]: unknown;
|
|
144
|
-
};
|
|
145
|
-
export type ResponsesObject = Record<string, ResponseObject | ReferenceObject>;
|
|
146
|
-
export type ResponseObject = {
|
|
147
|
-
description: string;
|
|
148
|
-
headers?: Record<string, HeaderObject | ReferenceObject>;
|
|
149
|
-
content?: Record<string, MediaTypeObject>;
|
|
150
|
-
links?: Record<string, LinkObject | ReferenceObject>;
|
|
151
|
-
[key: `x-${string}`]: unknown;
|
|
152
|
-
};
|
|
153
|
-
export type HeaderObject = Omit<ParameterObject, 'name' | 'in'>;
|
|
154
|
-
export type ExampleObject = {
|
|
155
|
-
summary?: string;
|
|
156
|
-
description?: string;
|
|
157
|
-
value?: unknown;
|
|
158
|
-
externalValue?: string;
|
|
159
|
-
[key: `x-${string}`]: unknown;
|
|
160
|
-
};
|
|
161
|
-
export type LinkObject = {
|
|
162
|
-
operationRef?: string;
|
|
163
|
-
operationId?: string;
|
|
164
|
-
parameters?: Record<string, unknown>;
|
|
165
|
-
requestBody?: unknown;
|
|
166
|
-
description?: string;
|
|
167
|
-
server?: ServerObject;
|
|
168
|
-
[key: `x-${string}`]: unknown;
|
|
169
|
-
};
|
|
170
|
-
export type CallbackObject = Record<string, PathItem>;
|
|
171
|
-
export type SecuritySchemeObject = {
|
|
172
|
-
type: 'apiKey' | 'http' | 'mutualTLS' | 'oauth2' | 'openIdConnect';
|
|
173
|
-
description?: string;
|
|
174
|
-
name?: string;
|
|
175
|
-
in?: 'query' | 'header' | 'cookie';
|
|
176
|
-
scheme?: string;
|
|
177
|
-
bearerFormat?: string;
|
|
178
|
-
flows?: OAuthFlowsObject;
|
|
179
|
-
openIdConnectUrl?: string;
|
|
180
|
-
[key: `x-${string}`]: unknown;
|
|
181
|
-
};
|
|
182
|
-
export type OAuthFlowsObject = {
|
|
183
|
-
implicit?: OAuthFlowObject;
|
|
184
|
-
password?: OAuthFlowObject;
|
|
185
|
-
clientCredentials?: OAuthFlowObject;
|
|
186
|
-
authorizationCode?: OAuthFlowObject;
|
|
187
|
-
[key: `x-${string}`]: unknown;
|
|
188
|
-
};
|
|
189
|
-
export type OAuthFlowObject = {
|
|
190
|
-
authorizationUrl?: string;
|
|
191
|
-
tokenUrl?: string;
|
|
192
|
-
refreshUrl?: string;
|
|
193
|
-
scopes: Record<string, string>;
|
|
194
|
-
[key: `x-${string}`]: unknown;
|
|
195
|
-
};
|
|
1
|
+
/** @deprecated Use imports from './openapi-document.js' instead */
|
|
2
|
+
export * from './openapi-document.js';
|
|
196
3
|
//# sourceMappingURL=swagger-document.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swagger-document.d.ts","sourceRoot":"","sources":["../src/swagger-document.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"swagger-document.d.ts","sourceRoot":"","sources":["../src/swagger-document.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,cAAc,uBAAuB,CAAA"}
|
package/esm/swagger-document.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swagger-document.js","sourceRoot":"","sources":["../src/swagger-document.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"swagger-document.js","sourceRoot":"","sources":["../src/swagger-document.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,cAAc,uBAAuB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@furystack/rest",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "Generic REST package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/furystack/furystack",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@furystack/core": "^15.2.
|
|
41
|
+
"@furystack/core": "^15.2.5",
|
|
42
42
|
"@furystack/inject": "^12.0.32"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@types/node": "^25.3.
|
|
45
|
+
"@types/node": "^25.3.5",
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
47
|
"vitest": "^4.0.18"
|
|
48
48
|
},
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import type { Method } from './methods.js'
|
|
2
|
+
import type {
|
|
3
|
+
ContactObject,
|
|
4
|
+
ExternalDocumentationObject,
|
|
5
|
+
LicenseObject,
|
|
6
|
+
SecuritySchemeObject,
|
|
7
|
+
ServerObject,
|
|
8
|
+
TagObject,
|
|
9
|
+
} from './openapi-document.js'
|
|
2
10
|
import type { RestApi } from './rest-api.js'
|
|
3
11
|
|
|
4
12
|
/**
|
|
5
|
-
* The JSON
|
|
13
|
+
* The JSON Schema type used for API endpoint definitions.
|
|
14
|
+
*
|
|
15
|
+
* This is intentionally `unknown` because the exact schema shape depends on
|
|
16
|
+
* the generator used (e.g. `ts-json-schema-generator` produces Draft 7-style
|
|
17
|
+
* objects with `definitions`, while consumed OpenAPI documents use 3.1-style
|
|
18
|
+
* objects). Narrowing to `object | boolean` would break runtime usages where
|
|
19
|
+
* the schema is `null` or omitted.
|
|
6
20
|
*/
|
|
7
|
-
export type Schema = unknown
|
|
21
|
+
export type Schema = unknown
|
|
8
22
|
|
|
9
23
|
/**
|
|
10
24
|
* Represents the definition of an API endpoint, including its path, schema, and schema name.
|
|
@@ -27,9 +41,47 @@ export type ApiEndpointDefinition = {
|
|
|
27
41
|
schemaName: string
|
|
28
42
|
/**
|
|
29
43
|
* Indicates whether the endpoint requires authentication.
|
|
30
|
-
* To include the flag, wrap your endpoint with an
|
|
44
|
+
* To include the flag, wrap your endpoint with an Authenticate() call during the implementation.
|
|
31
45
|
*/
|
|
32
46
|
isAuthenticated: boolean
|
|
47
|
+
/**
|
|
48
|
+
* Tags for API documentation grouping.
|
|
49
|
+
*/
|
|
50
|
+
tags?: string[]
|
|
51
|
+
/**
|
|
52
|
+
* Marks the endpoint as deprecated.
|
|
53
|
+
*/
|
|
54
|
+
deprecated?: boolean
|
|
55
|
+
/**
|
|
56
|
+
* A short summary of the endpoint.
|
|
57
|
+
*/
|
|
58
|
+
summary?: string
|
|
59
|
+
/**
|
|
60
|
+
* A longer description of the endpoint.
|
|
61
|
+
*/
|
|
62
|
+
description?: string
|
|
63
|
+
/**
|
|
64
|
+
* The OpenAPI security scheme names required for this endpoint.
|
|
65
|
+
* When present, used by `generateOpenApiDocument` to emit accurate per-operation `security`.
|
|
66
|
+
* When absent, falls back to the `isAuthenticated` boolean behavior.
|
|
67
|
+
*/
|
|
68
|
+
securitySchemes?: string[]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Document-level metadata preserved from/to OpenAPI documents.
|
|
73
|
+
* Carries info fields (contact, license, servers, tags, etc.) through the
|
|
74
|
+
* `openApiToSchema()` -> `generateOpenApiDocument()` round-trip.
|
|
75
|
+
*/
|
|
76
|
+
export type ApiDocumentMetadata = {
|
|
77
|
+
summary?: string
|
|
78
|
+
termsOfService?: string
|
|
79
|
+
contact?: ContactObject
|
|
80
|
+
license?: LicenseObject
|
|
81
|
+
servers?: ServerObject[]
|
|
82
|
+
tags?: TagObject[]
|
|
83
|
+
externalDocs?: ExternalDocumentationObject
|
|
84
|
+
securitySchemes?: Record<string, SecuritySchemeObject>
|
|
33
85
|
}
|
|
34
86
|
|
|
35
87
|
/**
|
|
@@ -54,6 +106,7 @@ export type ApiEndpointSchema<TApi extends RestApi = RestApi> = {
|
|
|
54
106
|
name: string
|
|
55
107
|
description: string
|
|
56
108
|
version: string
|
|
109
|
+
metadata?: ApiDocumentMetadata
|
|
57
110
|
endpoints: {
|
|
58
111
|
[TMethod in Method]?: TMethod extends keyof TApi
|
|
59
112
|
? TApi[TMethod] extends Record<string, unknown>
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,10 @@ export * from './api-endpoint-schema.js'
|
|
|
2
2
|
export * from './deserialize-query-string.js'
|
|
3
3
|
export * from './endpoint-models/index.js'
|
|
4
4
|
export * from './methods.js'
|
|
5
|
+
export * from './openapi-document.js'
|
|
6
|
+
export * from './openapi-resolve-refs.js'
|
|
7
|
+
export * from './openapi-to-rest-api.js'
|
|
8
|
+
export * from './openapi-to-schema.js'
|
|
5
9
|
export * from './request-error.js'
|
|
6
10
|
export * from './rest-api.js'
|
|
7
11
|
export * from './serialize-to-query-string.js'
|
|
8
|
-
export * from './swagger-document.js'
|