@kubb/ast 5.0.0-alpha.3 → 5.0.0-alpha.30

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.
@@ -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
  }
package/src/nodes/root.ts CHANGED
@@ -3,30 +3,61 @@ import type { OperationNode } from './operation.ts'
3
3
  import type { SchemaNode } from './schema.ts'
4
4
 
5
5
  /**
6
- * Format-agnostic metadata about the API document.
7
- * Adapters populate whichever fields are available in their source format.
6
+ * Basic metadata for an API document.
7
+ * Adapters fill fields that exist in their source format.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const meta: RootMeta = { title: 'Pet API', version: '1.0.0' }
12
+ * ```
8
13
  */
9
14
  export type RootMeta = {
10
- /** API title (from `info.title` in OAS/AsyncAPI). */
15
+ /**
16
+ * API title (from `info.title` in OAS/AsyncAPI).
17
+ */
11
18
  title?: string
12
- /** API version string (from `info.version` in OAS/AsyncAPI). */
19
+ /**
20
+ * API description (from `info.description` in OAS/AsyncAPI).
21
+ */
22
+ description?: string
23
+ /**
24
+ * API version string (from `info.version` in OAS/AsyncAPI).
25
+ */
13
26
  version?: string
14
27
  /**
15
- * Resolved base URL for the API.
16
- * OAS: derived from `servers[serverIndex].url` with variable substitution.
17
- * AsyncAPI: derived from `servers[serverIndex].url`.
18
- * Drizzle / schema-only formats: not set.
28
+ * Resolved API base URL.
29
+ * For OpenAPI and AsyncAPI, this comes from the selected server URL.
19
30
  */
20
31
  baseURL?: string
21
32
  }
22
33
 
23
34
  /**
24
- * Top-level container for all schemas and operations in a single API document.
35
+ * Root AST node that contains all schemas and operations for one API document.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const root: RootNode = {
40
+ * kind: 'Root',
41
+ * schemas: [],
42
+ * operations: [],
43
+ * }
44
+ * ```
25
45
  */
26
46
  export type RootNode = BaseNode & {
47
+ /**
48
+ * Node kind.
49
+ */
27
50
  kind: 'Root'
51
+ /**
52
+ * All schema nodes in the document.
53
+ */
28
54
  schemas: Array<SchemaNode>
55
+ /**
56
+ * All operation nodes in the document.
57
+ */
29
58
  operations: Array<OperationNode>
30
- /** Format-agnostic document metadata populated by the adapter. */
59
+ /**
60
+ * Optional document metadata populated by the adapter.
61
+ */
31
62
  meta?: RootMeta
32
63
  }