@kubb/ast 5.0.0-alpha.2 → 5.0.0-alpha.21

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/src/infer.ts ADDED
@@ -0,0 +1,130 @@
1
+ import type {
2
+ ArraySchemaNode,
3
+ DateSchemaNode,
4
+ DatetimeSchemaNode,
5
+ EnumSchemaNode,
6
+ IntersectionSchemaNode,
7
+ NumberSchemaNode,
8
+ ObjectSchemaNode,
9
+ RefSchemaNode,
10
+ ScalarSchemaNode,
11
+ SchemaNode,
12
+ StringSchemaNode,
13
+ TimeSchemaNode,
14
+ UnionSchemaNode,
15
+ UrlSchemaNode,
16
+ } from './nodes/index.ts'
17
+
18
+ /**
19
+ * Shared parser options used by OAS-to-AST inference and parser flows.
20
+ */
21
+ export type ParserOptions = {
22
+ /**
23
+ * How `format: 'date-time'` schemas are represented. `false` falls through to a plain string.
24
+ */
25
+ dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date'
26
+ /**
27
+ * Whether `type: 'integer'` and `format: 'int64'` produce `number` or `bigint` nodes.
28
+ */
29
+ integerType?: 'number' | 'bigint'
30
+ /**
31
+ * AST type used when no schema type can be inferred.
32
+ */
33
+ unknownType: 'any' | 'unknown' | 'void'
34
+ /**
35
+ * AST type used for completely empty schemas (`{}`).
36
+ */
37
+ emptySchemaType: 'any' | 'unknown' | 'void'
38
+ /**
39
+ * Suffix appended to derived enum names when building property schema names.
40
+ */
41
+ enumSuffix: 'enum' | (string & {})
42
+ }
43
+
44
+ /**
45
+ * Maps each `dateType` option value to the AST node produced by `format: 'date-time'`.
46
+ */
47
+ type DateTimeNodeByDateType = {
48
+ date: DateSchemaNode
49
+ string: DatetimeSchemaNode
50
+ stringOffset: DatetimeSchemaNode
51
+ stringLocal: DatetimeSchemaNode
52
+ false: StringSchemaNode
53
+ }
54
+
55
+ /**
56
+ * Resolves the AST node produced by `format: 'date-time'` based on the `dateType` option.
57
+ */
58
+ type ResolveDateTimeNode<TDateType extends ParserOptions['dateType']> = DateTimeNodeByDateType[TDateType extends keyof DateTimeNodeByDateType
59
+ ? TDateType
60
+ : 'string']
61
+
62
+ /**
63
+ * Ordered list of `[schema-shape, SchemaNode]` pairs.
64
+ * `InferSchemaNode` walks this tuple in order and returns the first matching node type.
65
+ */
66
+ type SchemaNodeMap<TDateType extends ParserOptions['dateType'] = 'string'> = [
67
+ [{ $ref: string }, RefSchemaNode],
68
+ [{ allOf: ReadonlyArray<unknown>; properties: object }, IntersectionSchemaNode],
69
+ [{ allOf: readonly [unknown, unknown, ...unknown[]] }, IntersectionSchemaNode],
70
+ [{ allOf: ReadonlyArray<unknown> }, SchemaNode],
71
+ [{ oneOf: ReadonlyArray<unknown> }, UnionSchemaNode],
72
+ [{ anyOf: ReadonlyArray<unknown> }, UnionSchemaNode],
73
+ [{ const: null }, ScalarSchemaNode],
74
+ [{ const: string | number | boolean }, EnumSchemaNode],
75
+ [{ type: ReadonlyArray<string> }, UnionSchemaNode],
76
+ [{ type: 'array'; enum: ReadonlyArray<unknown> }, ArraySchemaNode],
77
+ [{ enum: ReadonlyArray<unknown> }, EnumSchemaNode],
78
+ [{ type: 'enum' }, EnumSchemaNode],
79
+ [{ type: 'union' }, UnionSchemaNode],
80
+ [{ type: 'intersection' }, IntersectionSchemaNode],
81
+ [{ type: 'tuple' }, ArraySchemaNode],
82
+ [{ type: 'ref' }, RefSchemaNode],
83
+ [{ type: 'datetime' }, DatetimeSchemaNode],
84
+ [{ type: 'date' }, DateSchemaNode],
85
+ [{ type: 'time' }, TimeSchemaNode],
86
+ [{ type: 'url' }, UrlSchemaNode],
87
+ [{ type: 'object' }, ObjectSchemaNode],
88
+ [{ additionalProperties: boolean | {} }, ObjectSchemaNode],
89
+ [{ type: 'array' }, ArraySchemaNode],
90
+ [{ items: object }, ArraySchemaNode],
91
+ [{ prefixItems: ReadonlyArray<unknown> }, ArraySchemaNode],
92
+ [{ type: string; format: 'date-time' }, ResolveDateTimeNode<TDateType>],
93
+ [{ type: string; format: 'date' }, DateSchemaNode],
94
+ [{ type: string; format: 'time' }, TimeSchemaNode],
95
+ [{ format: 'date-time' }, ResolveDateTimeNode<TDateType>],
96
+ [{ format: 'date' }, DateSchemaNode],
97
+ [{ format: 'time' }, TimeSchemaNode],
98
+ [{ type: 'string' }, StringSchemaNode],
99
+ [{ type: 'number' }, NumberSchemaNode],
100
+ [{ type: 'integer' }, NumberSchemaNode],
101
+ [{ type: 'bigint' }, NumberSchemaNode],
102
+ [{ type: string }, ScalarSchemaNode],
103
+ [{ minLength: number }, StringSchemaNode],
104
+ [{ maxLength: number }, StringSchemaNode],
105
+ [{ pattern: string }, StringSchemaNode],
106
+ [{ minimum: number }, NumberSchemaNode],
107
+ [{ maximum: number }, NumberSchemaNode],
108
+ ]
109
+
110
+ /**
111
+ * Infers the matching AST `SchemaNode` type from an input schema shape.
112
+ */
113
+ export type InferSchemaNode<
114
+ TSchema extends object,
115
+ TDateType extends ParserOptions['dateType'] = 'string',
116
+ TEntries extends ReadonlyArray<[object, SchemaNode]> = SchemaNodeMap<TDateType>,
117
+ > = TEntries extends [infer TEntry extends [object, SchemaNode], ...infer TRest extends ReadonlyArray<[object, SchemaNode]>]
118
+ ? TSchema extends TEntry[0]
119
+ ? TEntry[1]
120
+ : InferSchemaNode<TSchema, TDateType, TRest>
121
+ : SchemaNode
122
+
123
+ /**
124
+ * Backward-compatible alias for `InferSchemaNode`.
125
+ */
126
+ export type InferSchema<
127
+ TSchema extends object,
128
+ TDateType extends ParserOptions['dateType'] = 'string',
129
+ TEntries extends ReadonlyArray<[object, SchemaNode]> = SchemaNodeMap<TDateType>,
130
+ > = InferSchemaNode<TSchema, TDateType, TEntries>
package/src/mocks.ts CHANGED
@@ -2,7 +2,7 @@ import { createOperation, createParameter, createProperty, createResponse, creat
2
2
  import type { RootNode } from './nodes/root.ts'
3
3
 
4
4
  /**
5
- * Minimal single-resource tree: one `Pet` schema and one `getPetById` operation.
5
+ * Builds a minimal sample AST with one `Pet` schema and one `getPetById` operation.
6
6
  */
7
7
  export function buildSampleTree(): RootNode {
8
8
  const petSchema = createSchema({
@@ -20,15 +20,22 @@ export function buildSampleTree(): RootNode {
20
20
  path: '/pets/{petId}',
21
21
  tags: ['pets'],
22
22
  parameters: [createParameter({ name: 'petId', in: 'path', schema: createSchema({ type: 'integer' }), required: true })],
23
- responses: [createResponse({ statusCode: '200', schema: createSchema({ type: 'ref', name: 'Pet' }) }), createResponse({ statusCode: '404' })],
23
+ responses: [
24
+ createResponse({ statusCode: '200', schema: createSchema({ type: 'ref', name: 'Pet' }) }),
25
+ createResponse({
26
+ statusCode: '404',
27
+ schema: createSchema({ type: 'ref', name: 'Error' }),
28
+ }),
29
+ ],
24
30
  })
25
31
 
26
32
  return createRoot({ schemas: [petSchema], operations: [operation] })
27
33
  }
28
34
 
29
35
  /**
30
- * PetStore-like tree: six named schemas (`Pet`, `NewPet`, `PetList`, `Error`, `PetOrError`, `FullPet`)
31
- * and two operations (`listPets`, `createPet`).
36
+ * Builds a PetStore-like fixture AST with:
37
+ * - six named schemas (`Pet`, `NewPet`, `PetList`, `Error`, `PetOrError`, `FullPet`)
38
+ * - two operations (`listPets`, `createPet`)
32
39
  */
33
40
  export function buildFixture(): RootNode {
34
41
  const refPet = createSchema({ type: 'ref', ref: 'Pet' })
@@ -92,7 +99,7 @@ export function buildFixture(): RootNode {
92
99
  method: 'POST',
93
100
  path: '/pets',
94
101
  tags: ['pets'],
95
- requestBody: createSchema({ type: 'ref', ref: 'NewPet' }),
102
+ requestBody: { schema: createSchema({ type: 'ref', ref: 'NewPet' }) },
96
103
  responses: [createResponse({ statusCode: '201', schema: refPet, mediaType: 'application/json' })],
97
104
  }),
98
105
  ],
package/src/nodes/base.ts CHANGED
@@ -1,16 +1,43 @@
1
1
  /**
2
- * Kind discriminant for every AST node.
2
+ * `kind` values used by AST nodes.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const kind: NodeKind = 'Schema'
7
+ * ```
3
8
  */
4
- export type NodeKind = 'Root' | 'Operation' | 'Schema' | 'Property' | 'Parameter' | 'Response'
9
+ export type NodeKind =
10
+ | 'Root'
11
+ | 'Operation'
12
+ | 'Schema'
13
+ | 'Property'
14
+ | 'Parameter'
15
+ | 'Response'
16
+ | 'FunctionParameter'
17
+ | 'ObjectBindingParameter'
18
+ | 'FunctionParameters'
5
19
 
6
20
  /**
7
- * Common base for all AST nodes.
21
+ * Base shape shared by all AST nodes.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const base: BaseNode = { kind: 'Root' }
26
+ * ```
8
27
  */
9
28
  export type BaseNode = {
29
+ /**
30
+ * Node discriminator.
31
+ */
10
32
  kind: NodeKind
11
33
  }
12
34
 
13
35
  /**
14
- * Any AST node.
36
+ * Minimal node type when only `kind` is needed.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const node: Node = { kind: 'Operation' }
41
+ * ```
15
42
  */
16
43
  export type Node = BaseNode
@@ -0,0 +1,131 @@
1
+ import type { BaseNode } from './base.ts'
2
+
3
+ /**
4
+ * AST node for one function parameter.
5
+ *
6
+ * @example Required parameter
7
+ * `name: Type`
8
+ *
9
+ * @example Optional param
10
+ * `name?: Type`
11
+ *
12
+ * @example Parameter with default
13
+ * `name: Type = defaultValue`
14
+ *
15
+ * @example Rest parameter
16
+ * `...name: Type[]`
17
+ */
18
+ export type FunctionParameterNode = BaseNode & {
19
+ /**
20
+ * Node kind.
21
+ */
22
+ kind: 'FunctionParameter'
23
+ /**
24
+ * Parameter name in the generated signature.
25
+ */
26
+ name: string
27
+ /**
28
+ * TypeScript type text, for example, `"string"` or `"Pet[]"`.
29
+ * Omit for untyped JavaScript output.
30
+ */
31
+ type?: string
32
+ /**
33
+ * When `true` the parameter is emitted as a rest parameter (`...name`).
34
+ * @default false
35
+ */
36
+ rest?: boolean
37
+ } /**
38
+ * Optional parameter, rendered with `?` in declarations.
39
+ * Cannot be combined with `default` because defaulted parameters are already optional.
40
+ * @example `name?: Type`
41
+ */ & (
42
+ | { optional: true; default?: never }
43
+ /**
44
+ * Required parameter, or parameter with a default value.
45
+ * @example Required: `name: Type`
46
+ * @example With default: `name: Type = default`
47
+ */
48
+ | { optional?: false; default?: string }
49
+ )
50
+
51
+ /**
52
+ * AST node for object-destructured function parameters.
53
+ *
54
+ * This node renders as `{ key1, key2 }: { key1: Type1; key2: Type2 } = {}` in declarations,
55
+ * or as individual top-level parameters when `inline` is `true`.
56
+ *
57
+ * This replaces `mode: 'object'` and `mode: 'inlineSpread'` from the old `FunctionParams` API.
58
+ *
59
+ * @example Object destructuring with auto-computed type (declaration)
60
+ * `{ id, name }: { id: string; name: string } = {}`
61
+ *
62
+ * @example Inline (spread) — children emitted as individual top-level params
63
+ * `id: string, name: string`
64
+ */
65
+ export type ObjectBindingParameterNode = BaseNode & {
66
+ /**
67
+ * Node kind.
68
+ */
69
+ kind: 'ObjectBindingParameter'
70
+ /**
71
+ * The individual parameters that form the destructured object.
72
+ * Rendered as `{ key1, key2 }` in declarations, or spread inline when `inline` is `true`.
73
+ */
74
+ properties: Array<FunctionParameterNode>
75
+ /**
76
+ * Optional type text for the full object parameter.
77
+ * When absent, the printer auto-computes `{ key1: Type1; key2: Type2 }` from `properties`.
78
+ */
79
+ type?: string
80
+ /**
81
+ * When `true`, `properties` are emitted as individual top-level parameters instead of
82
+ * being wrapped in a destructuring pattern (`{ key1, key2 }`).
83
+ *
84
+ * Equivalent to `mode: 'inlineSpread'` in the legacy `FunctionParams` API.
85
+ * @default false
86
+ */
87
+ inline?: boolean
88
+ /**
89
+ * Whether the full object binding is optional.
90
+ * If omitted, printers infer this from child properties.
91
+ */
92
+ optional?: boolean
93
+ /**
94
+ * Default value for the object group, written verbatim after `=`.
95
+ * Commonly `'{}'` to allow omitting the argument entirely.
96
+ */
97
+ default?: string
98
+ }
99
+
100
+ /**
101
+ * AST node for a complete function parameter list.
102
+ *
103
+ * Printers are responsible for sorting (`required` → `optional` → `defaulted`).
104
+ * Nodes are plain immutable data.
105
+ *
106
+ * Renders differently depending on the output mode:
107
+ * - `declaration` → `(id: string, config: Config = {})` — function declaration parameters
108
+ * - `call` → `(id, { method, url })` — function call arguments
109
+ * - `keys` → `{ id, config }` — key names only (for destructuring)
110
+ * - `values` → `{ id: id, config: config }` — key → value pairs
111
+ */
112
+ export type FunctionParametersNode = BaseNode & {
113
+ /**
114
+ * Node kind.
115
+ */
116
+ kind: 'FunctionParameters'
117
+ /**
118
+ * Ordered parameter nodes.
119
+ */
120
+ params: Array<FunctionParameterNode | ObjectBindingParameterNode>
121
+ }
122
+
123
+ /**
124
+ * The three function-signature AST node variants.
125
+ */
126
+ export type FunctionNode = FunctionParameterNode | ObjectBindingParameterNode | FunctionParametersNode
127
+
128
+ /**
129
+ * Handler map keys — one per `FunctionNode` kind.
130
+ */
131
+ export type FunctionNodeType = 'functionParameter' | 'objectBindingParameter' | 'functionParameters'
package/src/nodes/http.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * All IANA-registered HTTP status codes as string literals, matching how
3
- * they appear as keys in API specifications (e.g. `"200"`, `"404"`).
2
+ * All supported HTTP status code literals as strings, as used in API specs
3
+ * (for example, `"200"` and `"404"`).
4
4
  */
5
5
  export type HttpStatusCode =
6
6
  // 1xx Informational
@@ -72,13 +72,25 @@ export type HttpStatusCode =
72
72
  | '511'
73
73
 
74
74
  /**
75
- * A status code as used in an operation response: a specific HTTP status
76
- * code string or `"default"` as a catch-all fallback.
75
+ * Response status code literal used by operations.
76
+ *
77
+ * Includes specific HTTP status code strings and `"default"` for catch-all responses.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * const status: StatusCode = '200'
82
+ * const fallback: StatusCode = 'default'
83
+ * ```
77
84
  */
78
85
  export type StatusCode = HttpStatusCode | 'default'
79
86
 
80
87
  /**
81
- * Common IANA media types used in API request/response bodies.
88
+ * Supported media type strings used in request and response bodies.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * const mediaType: MediaType = 'application/json'
93
+ * ```
82
94
  */
83
95
  export type MediaType =
84
96
  // Application
@@ -1,3 +1,4 @@
1
+ import type { FunctionNode } from './function.ts'
1
2
  import type { OperationNode } from './operation.ts'
2
3
  import type { ParameterNode } from './parameter.ts'
3
4
  import type { PropertyNode } from './property.ts'
@@ -6,6 +7,7 @@ import type { RootNode } from './root.ts'
6
7
  import type { SchemaNode } from './schema.ts'
7
8
 
8
9
  export type { BaseNode, NodeKind } from './base.ts'
10
+ export type { FunctionNode, FunctionNodeType, FunctionParameterNode, FunctionParametersNode, ObjectBindingParameterNode } from './function.ts'
9
11
  export type { HttpStatusCode, MediaType, StatusCode } from './http.ts'
10
12
  export type { HttpMethod, OperationNode } from './operation.ts'
11
13
  export type { ParameterLocation, ParameterNode } from './parameter.ts'
@@ -33,13 +35,24 @@ export type {
33
35
  StringSchemaNode,
34
36
  TimeSchemaNode,
35
37
  UnionSchemaNode,
38
+ UrlSchemaNode,
36
39
  } from './schema.ts'
37
40
 
38
41
  /**
39
- * Discriminated union of every AST node.
42
+ * Union of all AST node types.
40
43
  *
41
- * Using a concrete union (instead of the bare `BaseNode` alias) lets
42
- * TypeScript narrow the type automatically inside `switch (node.kind)`
43
- * blocks, eliminating the need for manual `as TypeName` casts.
44
+ * This lets TypeScript narrow types in `switch (node.kind)` blocks.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * function getKind(node: Node): string {
49
+ * switch (node.kind) {
50
+ * case 'Root':
51
+ * return 'root'
52
+ * default:
53
+ * return 'other'
54
+ * }
55
+ * }
56
+ * ```
44
57
  */
45
- export type Node = RootNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode
58
+ export type Node = RootNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | FunctionNode
@@ -6,24 +6,81 @@ import type { SchemaNode } from './schema.ts'
6
6
  export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE'
7
7
 
8
8
  /**
9
- * A spec-agnostic representation of a single API operation.
9
+ * AST node representing one API operation.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const operation: OperationNode = {
14
+ * kind: 'Operation',
15
+ * operationId: 'listPets',
16
+ * method: 'GET',
17
+ * path: '/pets',
18
+ * tags: [],
19
+ * parameters: [],
20
+ * responses: [],
21
+ * }
22
+ * ```
10
23
  */
11
24
  export type OperationNode = BaseNode & {
25
+ /**
26
+ * Node kind.
27
+ */
12
28
  kind: 'Operation'
13
29
  /**
14
- * Unique operation identifier (maps to `operationId` in OAS).
30
+ * Operation identifier, usually from OpenAPI `operationId`.
15
31
  */
16
32
  operationId: string
33
+ /**
34
+ * HTTP Method like 'GET'
35
+ */
17
36
  method: HttpMethod
37
+ /**
38
+ * Express-style path string, for example `/pets/:petId`.
39
+ * OpenAPI `{param}` parts are converted to `:param`.
40
+ */
18
41
  path: string
42
+ /**
43
+ * Group labels for the operation.
44
+ * Usually copied from OpenAPI `tags`.
45
+ */
19
46
  tags: Array<string>
47
+ /**
48
+ * Short one-line operation summary.
49
+ */
20
50
  summary?: string
51
+ /**
52
+ * Full operation description.
53
+ */
21
54
  description?: string
55
+ /**
56
+ * Marks the operation as deprecated.
57
+ */
22
58
  deprecated?: boolean
59
+ /**
60
+ * Parameters that could be used, we have QueryParams, PathParams, HeaderParams and CookieParams
61
+ */
23
62
  parameters: Array<ParameterNode>
24
63
  /**
25
- * Request body schema. For OAS, this is the schema of the first content entry.
64
+ * Request body metadata for the operation.
65
+ */
66
+ requestBody?: {
67
+ /**
68
+ * Human-readable request body description.
69
+ */
70
+ description?: string
71
+ /**
72
+ * Request body schema.
73
+ * For OpenAPI, this is the schema from the first `content` entry.
74
+ */
75
+ schema?: SchemaNode
76
+ /**
77
+ * Property keys to exclude from the generated request body type via `Omit<Type, Keys>`.
78
+ * Set when a referenced schema has `readOnly` fields that should be omitted in request types.
79
+ */
80
+ keysToOmit?: Array<string>
81
+ }
82
+ /**
83
+ * Operation responses.
26
84
  */
27
- requestBody?: SchemaNode
28
85
  responses: Array<ResponseNode>
29
86
  }
@@ -4,12 +4,38 @@ import type { SchemaNode } from './schema.ts'
4
4
  export type ParameterLocation = 'path' | 'query' | 'header' | 'cookie'
5
5
 
6
6
  /**
7
- * A single input parameter for an operation.
7
+ * AST node representing one operation parameter.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const param: ParameterNode = {
12
+ * kind: 'Parameter',
13
+ * name: 'petId',
14
+ * in: 'path',
15
+ * schema: createSchema({ type: 'string' }),
16
+ * required: true,
17
+ * }
18
+ * ```
8
19
  */
9
20
  export type ParameterNode = BaseNode & {
21
+ /**
22
+ * Node kind.
23
+ */
10
24
  kind: 'Parameter'
25
+ /**
26
+ * Parameter name.
27
+ */
11
28
  name: string
29
+ /**
30
+ * Parameter location (`path`, `query`, `header`, or `cookie`).
31
+ */
12
32
  in: ParameterLocation
33
+ /**
34
+ * Parameter schema.
35
+ */
13
36
  schema: SchemaNode
37
+ /**
38
+ * Whether the parameter is required.
39
+ */
14
40
  required: boolean
15
41
  }
@@ -2,11 +2,33 @@ import type { BaseNode } from './base.ts'
2
2
  import type { SchemaNode } from './schema.ts'
3
3
 
4
4
  /**
5
- * A named property within an object schema.
5
+ * AST node representing one named object property.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const property: PropertyNode = {
10
+ * kind: 'Property',
11
+ * name: 'id',
12
+ * schema: createSchema({ type: 'integer' }),
13
+ * required: true,
14
+ * }
15
+ * ```
6
16
  */
7
17
  export type PropertyNode = BaseNode & {
18
+ /**
19
+ * Node kind.
20
+ */
8
21
  kind: 'Property'
22
+ /**
23
+ * Property key.
24
+ */
9
25
  name: string
26
+ /**
27
+ * Property schema.
28
+ */
10
29
  schema: SchemaNode
30
+ /**
31
+ * Whether the property is required.
32
+ */
11
33
  required: boolean
12
34
  }
@@ -3,15 +3,41 @@ import type { MediaType, StatusCode } from './http.ts'
3
3
  import type { SchemaNode } from './schema.ts'
4
4
 
5
5
  /**
6
- * A single response variant for an operation.
6
+ * AST node representing one operation response variant.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const response: ResponseNode = {
11
+ * kind: 'Response',
12
+ * statusCode: '200',
13
+ * schema: createSchema({ type: 'string' }),
14
+ * }
15
+ * ```
7
16
  */
8
17
  export type ResponseNode = BaseNode & {
18
+ /**
19
+ * Node kind.
20
+ */
9
21
  kind: 'Response'
10
22
  /**
11
23
  * HTTP status code or `'default'` for a fallback response.
12
24
  */
13
25
  statusCode: StatusCode
26
+ /**
27
+ * Optional response description.
28
+ */
14
29
  description?: string
15
- schema?: SchemaNode
16
- mediaType?: MediaType
30
+ /**
31
+ * Response body schema.
32
+ */
33
+ schema: SchemaNode
34
+ /**
35
+ * Response media type.
36
+ */
37
+ mediaType?: MediaType | null
38
+ /**
39
+ * Property keys to exclude from the generated type via `Omit<Type, Keys>`.
40
+ * Set when a referenced schema has `writeOnly` fields that should not appear in response types.
41
+ */
42
+ keysToOmit?: Array<string>
17
43
  }