@effect/platform 0.72.2 → 0.73.1
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/README.md +637 -0
- package/Url/package.json +6 -0
- package/dist/cjs/HttpApi.js.map +1 -1
- package/dist/cjs/HttpApiEndpoint.js.map +1 -1
- package/dist/cjs/HttpApiGroup.js.map +1 -1
- package/dist/cjs/HttpClient.js +8 -1
- package/dist/cjs/HttpClient.js.map +1 -1
- package/dist/cjs/HttpMethod.js +24 -1
- package/dist/cjs/HttpMethod.js.map +1 -1
- package/dist/cjs/OpenApi.js +82 -42
- package/dist/cjs/OpenApi.js.map +1 -1
- package/dist/cjs/Runtime.js.map +1 -1
- package/dist/cjs/Url.js +259 -0
- package/dist/cjs/Url.js.map +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/internal/httpClient.js +3 -1
- package/dist/cjs/internal/httpClient.js.map +1 -1
- package/dist/dts/HttpApi.d.ts +1 -2
- package/dist/dts/HttpApi.d.ts.map +1 -1
- package/dist/dts/HttpApiBuilder.d.ts +1 -1
- package/dist/dts/HttpApiBuilder.d.ts.map +1 -1
- package/dist/dts/HttpApiEndpoint.d.ts +16 -8
- package/dist/dts/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/dts/HttpApiGroup.d.ts +1 -2
- package/dist/dts/HttpApiGroup.d.ts.map +1 -1
- package/dist/dts/HttpClient.d.ts +22 -0
- package/dist/dts/HttpClient.d.ts.map +1 -1
- package/dist/dts/HttpMethod.d.ts +22 -0
- package/dist/dts/HttpMethod.d.ts.map +1 -1
- package/dist/dts/OpenApi.d.ts +100 -110
- package/dist/dts/OpenApi.d.ts.map +1 -1
- package/dist/dts/Runtime.d.ts +48 -0
- package/dist/dts/Runtime.d.ts.map +1 -1
- package/dist/dts/Url.d.ts +591 -0
- package/dist/dts/Url.d.ts.map +1 -0
- package/dist/dts/index.d.ts +4 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/esm/HttpApi.js.map +1 -1
- package/dist/esm/HttpApiEndpoint.js.map +1 -1
- package/dist/esm/HttpApiGroup.js.map +1 -1
- package/dist/esm/HttpClient.js +7 -0
- package/dist/esm/HttpClient.js.map +1 -1
- package/dist/esm/HttpMethod.js +22 -0
- package/dist/esm/HttpMethod.js.map +1 -1
- package/dist/esm/OpenApi.js +82 -41
- package/dist/esm/OpenApi.js.map +1 -1
- package/dist/esm/Runtime.js.map +1 -1
- package/dist/esm/Url.js +248 -0
- package/dist/esm/Url.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/httpClient.js +2 -0
- package/dist/esm/internal/httpClient.js.map +1 -1
- package/package.json +10 -2
- package/src/HttpApi.ts +2 -3
- package/src/HttpApiBuilder.ts +1 -1
- package/src/HttpApiEndpoint.ts +22 -13
- package/src/HttpApiGroup.ts +2 -3
- package/src/HttpClient.ts +28 -0
- package/src/HttpMethod.ts +24 -0
- package/src/OpenApi.ts +174 -181
- package/src/Runtime.ts +48 -0
- package/src/Url.ts +632 -0
- package/src/index.ts +5 -0
- package/src/internal/httpClient.ts +11 -0
package/src/OpenApi.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
|
+
import type { NonEmptyArray } from "effect/Array"
|
|
4
5
|
import * as Context from "effect/Context"
|
|
5
6
|
import { constFalse } from "effect/Function"
|
|
6
7
|
import { globalValue } from "effect/GlobalValue"
|
|
7
8
|
import * as Option from "effect/Option"
|
|
8
|
-
import type { ReadonlyRecord } from "effect/Record"
|
|
9
9
|
import type * as Schema from "effect/Schema"
|
|
10
10
|
import type * as AST from "effect/SchemaAST"
|
|
11
|
-
import type { DeepMutable, Mutable } from "effect/Types"
|
|
12
11
|
import * as HttpApi from "./HttpApi.js"
|
|
12
|
+
import type { HttpApiGroup } from "./HttpApiGroup.js"
|
|
13
13
|
import * as HttpApiMiddleware from "./HttpApiMiddleware.js"
|
|
14
14
|
import * as HttpApiSchema from "./HttpApiSchema.js"
|
|
15
15
|
import type { HttpApiSecurity } from "./HttpApiSecurity.js"
|
|
@@ -160,16 +160,68 @@ export const annotations: (
|
|
|
160
160
|
const apiCache = globalValue("@effect/platform/OpenApi/apiCache", () => new WeakMap<HttpApi.HttpApi.Any, OpenAPISpec>())
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
|
+
* This function checks if a given tag exists within the provided context. If
|
|
164
|
+
* the tag is present, it retrieves the associated value and applies the given
|
|
165
|
+
* callback function to it. If the tag is not found, the function does nothing.
|
|
166
|
+
*/
|
|
167
|
+
function processAnnotation<Services, S, I>(
|
|
168
|
+
ctx: Context.Context<Services>,
|
|
169
|
+
tag: Context.Tag<I, S>,
|
|
170
|
+
f: (s: S) => void
|
|
171
|
+
) {
|
|
172
|
+
const o = Context.getOption(ctx, tag)
|
|
173
|
+
if (Option.isSome(o)) {
|
|
174
|
+
f(o.value)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Converts an `HttpApi` instance into an OpenAPI Specification object.
|
|
180
|
+
*
|
|
181
|
+
* **Details**
|
|
182
|
+
*
|
|
183
|
+
* This function takes an `HttpApi` instance, which defines a structured API,
|
|
184
|
+
* and generates an OpenAPI Specification (`OpenAPISpec`). The resulting spec
|
|
185
|
+
* adheres to the OpenAPI 3.1.0 standard and includes detailed metadata such as
|
|
186
|
+
* paths, operations, security schemes, and components. The function processes
|
|
187
|
+
* the API's annotations, middleware, groups, and endpoints to build a complete
|
|
188
|
+
* and accurate representation of the API in OpenAPI format.
|
|
189
|
+
*
|
|
190
|
+
* The function also deduplicates schemas, applies transformations, and
|
|
191
|
+
* integrates annotations like descriptions, summaries, external documentation,
|
|
192
|
+
* and overrides. Cached results are used for better performance when the same
|
|
193
|
+
* `HttpApi` instance is processed multiple times.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* import { HttpApi, HttpApiEndpoint, HttpApiGroup, OpenApi } from "@effect/platform"
|
|
198
|
+
* import { Schema } from "effect"
|
|
199
|
+
*
|
|
200
|
+
* const api = HttpApi.make("api").add(
|
|
201
|
+
* HttpApiGroup.make("group").add(
|
|
202
|
+
* HttpApiEndpoint.get("get", "/items")
|
|
203
|
+
* .addSuccess(Schema.Array(Schema.String))
|
|
204
|
+
* )
|
|
205
|
+
* )
|
|
206
|
+
*
|
|
207
|
+
* const spec = OpenApi.fromApi(api)
|
|
208
|
+
*
|
|
209
|
+
* // console.log(JSON.stringify(spec, null, 2))
|
|
210
|
+
* // Output: OpenAPI specification in JSON format
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
163
213
|
* @category constructors
|
|
164
214
|
* @since 1.0.0
|
|
165
215
|
*/
|
|
166
|
-
export const fromApi = <
|
|
167
|
-
|
|
168
|
-
|
|
216
|
+
export const fromApi = <Id extends string, Groups extends HttpApiGroup.Any, E, R>(
|
|
217
|
+
api: HttpApi.HttpApi<Id, Groups, E, R>
|
|
218
|
+
): OpenAPISpec => {
|
|
219
|
+
const cached = apiCache.get(api)
|
|
220
|
+
if (cached !== undefined) {
|
|
221
|
+
return cached
|
|
169
222
|
}
|
|
170
|
-
const api = self as unknown as HttpApi.HttpApi.AnyWithProps
|
|
171
223
|
const jsonSchemaDefs: Record<string, JsonSchema.JsonSchema> = {}
|
|
172
|
-
let spec:
|
|
224
|
+
let spec: OpenAPISpec = {
|
|
173
225
|
openapi: "3.1.0",
|
|
174
226
|
info: {
|
|
175
227
|
title: Context.getOrElse(api.annotations, Title, () => "Api"),
|
|
@@ -184,48 +236,45 @@ export const fromApi = <A extends HttpApi.HttpApi.Any>(self: A): OpenAPISpec =>
|
|
|
184
236
|
tags: []
|
|
185
237
|
}
|
|
186
238
|
|
|
187
|
-
function
|
|
239
|
+
function processAST(ast: AST.AST): JsonSchema.JsonSchema {
|
|
188
240
|
return JsonSchema.fromAST(ast, {
|
|
189
241
|
defs: jsonSchemaDefs
|
|
190
242
|
})
|
|
191
243
|
}
|
|
192
244
|
|
|
193
|
-
function
|
|
245
|
+
function processHttpApiSecurity(
|
|
194
246
|
name: string,
|
|
195
247
|
security: HttpApiSecurity
|
|
196
248
|
) {
|
|
197
|
-
if (spec.components
|
|
249
|
+
if (spec.components.securitySchemes[name] !== undefined) {
|
|
198
250
|
return
|
|
199
251
|
}
|
|
200
|
-
|
|
201
|
-
spec.components!.securitySchemes![name] = scheme
|
|
252
|
+
spec.components.securitySchemes[name] = makeSecurityScheme(security)
|
|
202
253
|
}
|
|
203
254
|
|
|
204
|
-
|
|
205
|
-
componentSchemas.forEach((componentSchema) =>
|
|
255
|
+
processAnnotation(api.annotations, HttpApi.AdditionalSchemas, (componentSchemas) => {
|
|
256
|
+
componentSchemas.forEach((componentSchema) => processAST(componentSchema.ast))
|
|
206
257
|
})
|
|
207
|
-
|
|
258
|
+
processAnnotation(api.annotations, Description, (description) => {
|
|
208
259
|
spec.info.description = description
|
|
209
260
|
})
|
|
210
|
-
|
|
261
|
+
processAnnotation(api.annotations, License, (license) => {
|
|
211
262
|
spec.info.license = license
|
|
212
263
|
})
|
|
213
|
-
|
|
264
|
+
processAnnotation(api.annotations, Summary, (summary) => {
|
|
214
265
|
spec.info.summary = summary
|
|
215
266
|
})
|
|
216
|
-
|
|
217
|
-
spec.servers = servers
|
|
218
|
-
})
|
|
219
|
-
Option.map(Context.getOption(api.annotations, Override), (override) => {
|
|
220
|
-
Object.assign(spec, override)
|
|
267
|
+
processAnnotation(api.annotations, Servers, (servers) => {
|
|
268
|
+
spec.servers = [...servers]
|
|
221
269
|
})
|
|
270
|
+
|
|
222
271
|
api.middlewares.forEach((middleware) => {
|
|
223
272
|
if (!HttpApiMiddleware.isSecurity(middleware)) {
|
|
224
273
|
return
|
|
225
274
|
}
|
|
226
275
|
for (const [name, security] of Object.entries(middleware.security)) {
|
|
227
|
-
|
|
228
|
-
spec.security
|
|
276
|
+
processHttpApiSecurity(name, security)
|
|
277
|
+
spec.security.push({ [name]: [] })
|
|
229
278
|
}
|
|
230
279
|
})
|
|
231
280
|
HttpApi.reflect(api, {
|
|
@@ -233,28 +282,30 @@ export const fromApi = <A extends HttpApi.HttpApi.Any>(self: A): OpenAPISpec =>
|
|
|
233
282
|
if (Context.get(group.annotations, Exclude)) {
|
|
234
283
|
return
|
|
235
284
|
}
|
|
236
|
-
let tag:
|
|
285
|
+
let tag: OpenAPISpecTag = {
|
|
237
286
|
name: Context.getOrElse(group.annotations, Title, () => group.identifier)
|
|
238
287
|
}
|
|
239
|
-
|
|
288
|
+
|
|
289
|
+
processAnnotation(group.annotations, Description, (description) => {
|
|
240
290
|
tag.description = description
|
|
241
291
|
})
|
|
242
|
-
|
|
292
|
+
processAnnotation(group.annotations, ExternalDocs, (externalDocs) => {
|
|
243
293
|
tag.externalDocs = externalDocs
|
|
244
294
|
})
|
|
245
|
-
|
|
295
|
+
processAnnotation(group.annotations, Override, (override) => {
|
|
246
296
|
Object.assign(tag, override)
|
|
247
297
|
})
|
|
248
|
-
|
|
249
|
-
tag =
|
|
298
|
+
processAnnotation(group.annotations, Transform, (transformFn) => {
|
|
299
|
+
tag = transformFn(tag) as OpenAPISpecTag
|
|
250
300
|
})
|
|
251
|
-
|
|
301
|
+
|
|
302
|
+
spec.tags.push(tag)
|
|
252
303
|
},
|
|
253
304
|
onEndpoint({ endpoint, errors, group, mergedAnnotations, middleware, payloads, successes }) {
|
|
254
305
|
if (Context.get(mergedAnnotations, Exclude)) {
|
|
255
306
|
return
|
|
256
307
|
}
|
|
257
|
-
let op:
|
|
308
|
+
let op: OpenAPISpecOperation = {
|
|
258
309
|
tags: [Context.getOrElse(group.annotations, Title, () => group.identifier)],
|
|
259
310
|
operationId: Context.getOrElse(
|
|
260
311
|
endpoint.annotations,
|
|
@@ -274,17 +325,17 @@ export const fromApi = <A extends HttpApi.HttpApi.Any>(self: A): OpenAPISpec =>
|
|
|
274
325
|
defaultDescription: () => string
|
|
275
326
|
) {
|
|
276
327
|
for (const [status, { ast, description }] of map) {
|
|
277
|
-
if (op.responses
|
|
278
|
-
op.responses
|
|
328
|
+
if (op.responses[status]) continue
|
|
329
|
+
op.responses[status] = {
|
|
279
330
|
description: Option.getOrElse(description, defaultDescription)
|
|
280
331
|
}
|
|
281
332
|
ast.pipe(
|
|
282
333
|
Option.filter((ast) => !HttpApiSchema.getEmptyDecodeable(ast)),
|
|
283
334
|
Option.map((ast) => {
|
|
284
335
|
const encoding = HttpApiSchema.getEncoding(ast)
|
|
285
|
-
op.responses
|
|
336
|
+
op.responses[status].content = {
|
|
286
337
|
[encoding.contentType]: {
|
|
287
|
-
schema:
|
|
338
|
+
schema: processAST(ast)
|
|
288
339
|
}
|
|
289
340
|
}
|
|
290
341
|
})
|
|
@@ -294,10 +345,10 @@ export const fromApi = <A extends HttpApi.HttpApi.Any>(self: A): OpenAPISpec =>
|
|
|
294
345
|
|
|
295
346
|
function processParameters(schema: Option.Option<Schema.Schema.All>, i: OpenAPISpecParameter["in"]) {
|
|
296
347
|
if (Option.isSome(schema)) {
|
|
297
|
-
const jsonSchema =
|
|
348
|
+
const jsonSchema = processAST(schema.value.ast)
|
|
298
349
|
if ("properties" in jsonSchema) {
|
|
299
350
|
Object.entries(jsonSchema.properties).forEach(([name, psJsonSchema]) => {
|
|
300
|
-
op.parameters
|
|
351
|
+
op.parameters.push({
|
|
301
352
|
name,
|
|
302
353
|
in: i,
|
|
303
354
|
schema: psJsonSchema,
|
|
@@ -309,33 +360,34 @@ export const fromApi = <A extends HttpApi.HttpApi.Any>(self: A): OpenAPISpec =>
|
|
|
309
360
|
}
|
|
310
361
|
}
|
|
311
362
|
|
|
312
|
-
|
|
363
|
+
processAnnotation(endpoint.annotations, Description, (description) => {
|
|
313
364
|
op.description = description
|
|
314
365
|
})
|
|
315
|
-
|
|
366
|
+
processAnnotation(endpoint.annotations, Summary, (summary) => {
|
|
316
367
|
op.summary = summary
|
|
317
368
|
})
|
|
318
|
-
|
|
369
|
+
processAnnotation(endpoint.annotations, Deprecated, (deprecated) => {
|
|
319
370
|
op.deprecated = deprecated
|
|
320
371
|
})
|
|
321
|
-
|
|
372
|
+
processAnnotation(endpoint.annotations, ExternalDocs, (externalDocs) => {
|
|
322
373
|
op.externalDocs = externalDocs
|
|
323
374
|
})
|
|
375
|
+
|
|
324
376
|
middleware.forEach((middleware) => {
|
|
325
377
|
if (!HttpApiMiddleware.isSecurity(middleware)) {
|
|
326
378
|
return
|
|
327
379
|
}
|
|
328
380
|
for (const [name, security] of Object.entries(middleware.security)) {
|
|
329
|
-
|
|
330
|
-
op.security
|
|
381
|
+
processHttpApiSecurity(name, security)
|
|
382
|
+
op.security.push({ [name]: [] })
|
|
331
383
|
}
|
|
332
384
|
})
|
|
333
385
|
const hasBody = HttpMethod.hasBody(endpoint.method)
|
|
334
386
|
if (hasBody && payloads.size > 0) {
|
|
335
|
-
const content:
|
|
387
|
+
const content: OpenApiSpecContent = {}
|
|
336
388
|
payloads.forEach(({ ast }, contentType) => {
|
|
337
389
|
content[contentType as OpenApiSpecContentType] = {
|
|
338
|
-
schema:
|
|
390
|
+
schema: processAST(ast)
|
|
339
391
|
}
|
|
340
392
|
})
|
|
341
393
|
op.requestBody = { content, required: true }
|
|
@@ -356,28 +408,33 @@ export const fromApi = <A extends HttpApi.HttpApi.Any>(self: A): OpenAPISpec =>
|
|
|
356
408
|
if (!spec.paths[path]) {
|
|
357
409
|
spec.paths[path] = {}
|
|
358
410
|
}
|
|
359
|
-
|
|
411
|
+
|
|
412
|
+
processAnnotation(endpoint.annotations, Override, (override) => {
|
|
360
413
|
Object.assign(op, override)
|
|
361
414
|
})
|
|
362
|
-
|
|
363
|
-
op = transformFn(op)
|
|
415
|
+
processAnnotation(endpoint.annotations, Transform, (transformFn) => {
|
|
416
|
+
op = transformFn(op) as OpenAPISpecOperation
|
|
364
417
|
})
|
|
418
|
+
|
|
365
419
|
spec.paths[path][method] = op
|
|
366
420
|
}
|
|
367
421
|
})
|
|
368
422
|
|
|
369
|
-
|
|
423
|
+
processAnnotation(api.annotations, Override, (override) => {
|
|
424
|
+
Object.assign(spec, override)
|
|
425
|
+
})
|
|
426
|
+
processAnnotation(api.annotations, Transform, (transformFn) => {
|
|
370
427
|
spec = transformFn(spec) as OpenAPISpec
|
|
371
428
|
})
|
|
372
429
|
|
|
373
|
-
apiCache.set(
|
|
430
|
+
apiCache.set(api, spec)
|
|
374
431
|
|
|
375
432
|
return spec
|
|
376
433
|
}
|
|
377
434
|
|
|
378
435
|
const makeSecurityScheme = (security: HttpApiSecurity): OpenAPISecurityScheme => {
|
|
379
|
-
const meta:
|
|
380
|
-
|
|
436
|
+
const meta: Partial<OpenAPISecurityScheme> = {}
|
|
437
|
+
processAnnotation(security.annotations, Description, (description) => {
|
|
381
438
|
meta.description = description
|
|
382
439
|
})
|
|
383
440
|
switch (security._tag) {
|
|
@@ -412,18 +469,21 @@ const makeSecurityScheme = (security: HttpApiSecurity): OpenAPISecurityScheme =>
|
|
|
412
469
|
}
|
|
413
470
|
|
|
414
471
|
/**
|
|
472
|
+
* This model describes the OpenAPI specification (version 3.1.0) returned by
|
|
473
|
+
* {@link fromApi}. It is not intended to describe the entire OpenAPI
|
|
474
|
+
* specification, only the output of `fromApi`.
|
|
475
|
+
*
|
|
415
476
|
* @category models
|
|
416
477
|
* @since 1.0.0
|
|
417
478
|
*/
|
|
418
479
|
export interface OpenAPISpec {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
readonly externalDocs?: OpenAPISpecExternalDocs
|
|
480
|
+
openapi: "3.1.0"
|
|
481
|
+
info: OpenAPISpecInfo
|
|
482
|
+
paths: OpenAPISpecPaths
|
|
483
|
+
components: OpenAPIComponents
|
|
484
|
+
security: Array<OpenAPISecurityRequirement>
|
|
485
|
+
tags: Array<OpenAPISpecTag>
|
|
486
|
+
servers?: Array<OpenAPISpecServer>
|
|
427
487
|
}
|
|
428
488
|
|
|
429
489
|
/**
|
|
@@ -431,11 +491,11 @@ export interface OpenAPISpec {
|
|
|
431
491
|
* @since 1.0.0
|
|
432
492
|
*/
|
|
433
493
|
export interface OpenAPISpecInfo {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
494
|
+
title: string
|
|
495
|
+
version: string
|
|
496
|
+
description?: string
|
|
497
|
+
license?: OpenAPISpecLicense
|
|
498
|
+
summary?: string
|
|
439
499
|
}
|
|
440
500
|
|
|
441
501
|
/**
|
|
@@ -443,9 +503,9 @@ export interface OpenAPISpecInfo {
|
|
|
443
503
|
* @since 1.0.0
|
|
444
504
|
*/
|
|
445
505
|
export interface OpenAPISpecTag {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
506
|
+
name: string
|
|
507
|
+
description?: string
|
|
508
|
+
externalDocs?: OpenAPISpecExternalDocs
|
|
449
509
|
}
|
|
450
510
|
|
|
451
511
|
/**
|
|
@@ -453,8 +513,8 @@ export interface OpenAPISpecTag {
|
|
|
453
513
|
* @since 1.0.0
|
|
454
514
|
*/
|
|
455
515
|
export interface OpenAPISpecExternalDocs {
|
|
456
|
-
|
|
457
|
-
|
|
516
|
+
url: string
|
|
517
|
+
description?: string
|
|
458
518
|
}
|
|
459
519
|
|
|
460
520
|
/**
|
|
@@ -462,8 +522,8 @@ export interface OpenAPISpecExternalDocs {
|
|
|
462
522
|
* @since 1.0.0
|
|
463
523
|
*/
|
|
464
524
|
export interface OpenAPISpecLicense {
|
|
465
|
-
|
|
466
|
-
|
|
525
|
+
name: string
|
|
526
|
+
url?: string
|
|
467
527
|
}
|
|
468
528
|
|
|
469
529
|
/**
|
|
@@ -471,9 +531,9 @@ export interface OpenAPISpecLicense {
|
|
|
471
531
|
* @since 1.0.0
|
|
472
532
|
*/
|
|
473
533
|
export interface OpenAPISpecServer {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
534
|
+
url: string
|
|
535
|
+
description?: string
|
|
536
|
+
variables?: Record<string, OpenAPISpecServerVariable>
|
|
477
537
|
}
|
|
478
538
|
|
|
479
539
|
/**
|
|
@@ -481,19 +541,16 @@ export interface OpenAPISpecServer {
|
|
|
481
541
|
* @since 1.0.0
|
|
482
542
|
*/
|
|
483
543
|
export interface OpenAPISpecServerVariable {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
544
|
+
default: string
|
|
545
|
+
enum?: NonEmptyArray<string>
|
|
546
|
+
description?: string
|
|
487
547
|
}
|
|
488
548
|
|
|
489
549
|
/**
|
|
490
550
|
* @category models
|
|
491
551
|
* @since 1.0.0
|
|
492
552
|
*/
|
|
493
|
-
export type OpenAPISpecPaths =
|
|
494
|
-
string,
|
|
495
|
-
OpenAPISpecPathItem
|
|
496
|
-
>
|
|
553
|
+
export type OpenAPISpecPaths = Record<string, OpenAPISpecPathItem>
|
|
497
554
|
|
|
498
555
|
/**
|
|
499
556
|
* @category models
|
|
@@ -513,28 +570,20 @@ export type OpenAPISpecMethodName =
|
|
|
513
570
|
* @category models
|
|
514
571
|
* @since 1.0.0
|
|
515
572
|
*/
|
|
516
|
-
export type OpenAPISpecPathItem =
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
520
|
-
& {
|
|
521
|
-
readonly summary?: string
|
|
522
|
-
readonly description?: string
|
|
523
|
-
readonly parameters?: Array<OpenAPISpecParameter>
|
|
524
|
-
}
|
|
573
|
+
export type OpenAPISpecPathItem = {
|
|
574
|
+
[K in OpenAPISpecMethodName]?: OpenAPISpecOperation
|
|
575
|
+
}
|
|
525
576
|
|
|
526
577
|
/**
|
|
527
578
|
* @category models
|
|
528
579
|
* @since 1.0.0
|
|
529
580
|
*/
|
|
530
581
|
export interface OpenAPISpecParameter {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
readonly deprecated?: boolean
|
|
537
|
-
readonly allowEmptyValue?: boolean
|
|
582
|
+
name: string
|
|
583
|
+
in: "query" | "header" | "path" | "cookie"
|
|
584
|
+
schema: JsonSchema.JsonSchema
|
|
585
|
+
required: boolean
|
|
586
|
+
description?: string
|
|
538
587
|
}
|
|
539
588
|
|
|
540
589
|
/**
|
|
@@ -559,35 +608,16 @@ export type OpenApiSpecContentType =
|
|
|
559
608
|
* @since 1.0.0
|
|
560
609
|
*/
|
|
561
610
|
export type OpenApiSpecContent = {
|
|
562
|
-
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* @category models
|
|
567
|
-
* @since 1.0.0
|
|
568
|
-
*/
|
|
569
|
-
export interface OpenApiSpecResponseHeader {
|
|
570
|
-
readonly description?: string
|
|
571
|
-
readonly schema: JsonSchema.JsonSchema
|
|
611
|
+
[K in OpenApiSpecContentType]?: OpenApiSpecMediaType
|
|
572
612
|
}
|
|
573
613
|
|
|
574
|
-
/**
|
|
575
|
-
* @category models
|
|
576
|
-
* @since 1.0.0
|
|
577
|
-
*/
|
|
578
|
-
export type OpenApiSpecResponseHeaders = ReadonlyRecord<
|
|
579
|
-
string,
|
|
580
|
-
OpenApiSpecResponseHeader
|
|
581
|
-
>
|
|
582
|
-
|
|
583
614
|
/**
|
|
584
615
|
* @category models
|
|
585
616
|
* @since 1.0.0
|
|
586
617
|
*/
|
|
587
618
|
export interface OpenApiSpecResponse {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
readonly description: string
|
|
619
|
+
description: string
|
|
620
|
+
content?: OpenApiSpecContent
|
|
591
621
|
}
|
|
592
622
|
|
|
593
623
|
/**
|
|
@@ -595,9 +625,7 @@ export interface OpenApiSpecResponse {
|
|
|
595
625
|
* @since 1.0.0
|
|
596
626
|
*/
|
|
597
627
|
export interface OpenApiSpecMediaType {
|
|
598
|
-
|
|
599
|
-
readonly example?: object
|
|
600
|
-
readonly description?: string
|
|
628
|
+
schema: JsonSchema.JsonSchema
|
|
601
629
|
}
|
|
602
630
|
|
|
603
631
|
/**
|
|
@@ -605,9 +633,8 @@ export interface OpenApiSpecMediaType {
|
|
|
605
633
|
* @since 1.0.0
|
|
606
634
|
*/
|
|
607
635
|
export interface OpenAPISpecRequestBody {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
readonly required?: boolean
|
|
636
|
+
content: OpenApiSpecContent
|
|
637
|
+
required: true
|
|
611
638
|
}
|
|
612
639
|
|
|
613
640
|
/**
|
|
@@ -615,8 +642,8 @@ export interface OpenAPISpecRequestBody {
|
|
|
615
642
|
* @since 1.0.0
|
|
616
643
|
*/
|
|
617
644
|
export interface OpenAPIComponents {
|
|
618
|
-
|
|
619
|
-
|
|
645
|
+
schemas: Record<string, JsonSchema.JsonSchema>
|
|
646
|
+
securitySchemes: Record<string, OpenAPISecurityScheme>
|
|
620
647
|
}
|
|
621
648
|
|
|
622
649
|
/**
|
|
@@ -625,10 +652,10 @@ export interface OpenAPIComponents {
|
|
|
625
652
|
*/
|
|
626
653
|
export interface OpenAPIHTTPSecurityScheme {
|
|
627
654
|
readonly type: "http"
|
|
628
|
-
|
|
629
|
-
|
|
655
|
+
scheme: "bearer" | "basic" | string
|
|
656
|
+
description?: string
|
|
630
657
|
/* only for scheme: 'bearer' */
|
|
631
|
-
|
|
658
|
+
bearerFormat?: string
|
|
632
659
|
}
|
|
633
660
|
|
|
634
661
|
/**
|
|
@@ -637,41 +664,9 @@ export interface OpenAPIHTTPSecurityScheme {
|
|
|
637
664
|
*/
|
|
638
665
|
export interface OpenAPIApiKeySecurityScheme {
|
|
639
666
|
readonly type: "apiKey"
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* @category models
|
|
647
|
-
* @since 1.0.0
|
|
648
|
-
*/
|
|
649
|
-
export interface OpenAPIMutualTLSSecurityScheme {
|
|
650
|
-
readonly type: "mutualTLS"
|
|
651
|
-
readonly description?: string
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
/**
|
|
655
|
-
* @category models
|
|
656
|
-
* @since 1.0.0
|
|
657
|
-
*/
|
|
658
|
-
export interface OpenAPIOAuth2SecurityScheme {
|
|
659
|
-
readonly type: "oauth2"
|
|
660
|
-
readonly description?: string
|
|
661
|
-
readonly flows: ReadonlyRecord<
|
|
662
|
-
"implicit" | "password" | "clientCredentials" | "authorizationCode",
|
|
663
|
-
ReadonlyRecord<string, unknown>
|
|
664
|
-
>
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* @category models
|
|
669
|
-
* @since 1.0.0
|
|
670
|
-
*/
|
|
671
|
-
export interface OpenAPIOpenIdConnectSecurityScheme {
|
|
672
|
-
readonly type: "openIdConnect"
|
|
673
|
-
readonly description?: string
|
|
674
|
-
readonly openIdConnectUrl: string
|
|
667
|
+
name: string
|
|
668
|
+
in: "query" | "header" | "cookie"
|
|
669
|
+
description?: string
|
|
675
670
|
}
|
|
676
671
|
|
|
677
672
|
/**
|
|
@@ -681,29 +676,27 @@ export interface OpenAPIOpenIdConnectSecurityScheme {
|
|
|
681
676
|
export type OpenAPISecurityScheme =
|
|
682
677
|
| OpenAPIHTTPSecurityScheme
|
|
683
678
|
| OpenAPIApiKeySecurityScheme
|
|
684
|
-
| OpenAPIMutualTLSSecurityScheme
|
|
685
|
-
| OpenAPIOAuth2SecurityScheme
|
|
686
|
-
| OpenAPIOpenIdConnectSecurityScheme
|
|
687
679
|
|
|
688
680
|
/**
|
|
689
681
|
* @category models
|
|
690
682
|
* @since 1.0.0
|
|
691
683
|
*/
|
|
692
|
-
export type OpenAPISecurityRequirement =
|
|
684
|
+
export type OpenAPISecurityRequirement = Record<string, Array<string>>
|
|
693
685
|
|
|
694
686
|
/**
|
|
695
687
|
* @category models
|
|
696
688
|
* @since 1.0.0
|
|
697
689
|
*/
|
|
698
690
|
export interface OpenAPISpecOperation {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
691
|
+
operationId: string
|
|
692
|
+
parameters: Array<OpenAPISpecParameter>
|
|
693
|
+
responses: OpenAPISpecResponses
|
|
694
|
+
/** Always contains at least the title annotation or the group identifier */
|
|
695
|
+
tags: NonEmptyArray<string>
|
|
696
|
+
security: Array<OpenAPISecurityRequirement>
|
|
697
|
+
requestBody?: OpenAPISpecRequestBody
|
|
698
|
+
description?: string
|
|
699
|
+
summary?: string
|
|
700
|
+
deprecated?: boolean
|
|
701
|
+
externalDocs?: OpenAPISpecExternalDocs
|
|
709
702
|
}
|