@skmtc/core 0.0.790 → 0.0.792

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.
Files changed (61) hide show
  1. package/esm/helpers/naming.d.ts +65 -1
  2. package/esm/helpers/naming.d.ts.map +1 -1
  3. package/esm/helpers/naming.js +65 -1
  4. package/esm/oas/example/Example.d.ts +81 -1
  5. package/esm/oas/example/Example.d.ts.map +1 -1
  6. package/esm/oas/example/Example.js +74 -1
  7. package/esm/oas/header/Header.d.ts +217 -1
  8. package/esm/oas/header/Header.d.ts.map +1 -1
  9. package/esm/oas/header/Header.js +207 -1
  10. package/esm/oas/info/Info.d.ts +72 -0
  11. package/esm/oas/info/Info.d.ts.map +1 -1
  12. package/esm/oas/info/Info.js +62 -0
  13. package/esm/oas/mediaType/MediaType.d.ts +85 -0
  14. package/esm/oas/mediaType/MediaType.d.ts.map +1 -1
  15. package/esm/oas/mediaType/MediaType.js +77 -0
  16. package/esm/oas/number/Number.d.ts +179 -1
  17. package/esm/oas/number/Number.d.ts.map +1 -1
  18. package/esm/oas/number/Number.js +161 -1
  19. package/esm/oas/pathItem/PathItem.d.ts +92 -0
  20. package/esm/oas/pathItem/PathItem.d.ts.map +1 -1
  21. package/esm/oas/pathItem/PathItem.js +85 -0
  22. package/esm/oas/requestBody/RequestBody.d.ts +264 -0
  23. package/esm/oas/requestBody/RequestBody.d.ts.map +1 -1
  24. package/esm/oas/requestBody/RequestBody.js +257 -0
  25. package/esm/oas/response/Response.d.ts +190 -0
  26. package/esm/oas/response/Response.d.ts.map +1 -1
  27. package/esm/oas/response/Response.js +183 -0
  28. package/esm/oas/void/Void.d.ts +130 -3
  29. package/esm/oas/void/Void.d.ts.map +1 -1
  30. package/esm/oas/void/Void.js +125 -3
  31. package/package.json +1 -1
  32. package/script/helpers/naming.d.ts +65 -1
  33. package/script/helpers/naming.d.ts.map +1 -1
  34. package/script/helpers/naming.js +65 -1
  35. package/script/oas/example/Example.d.ts +81 -1
  36. package/script/oas/example/Example.d.ts.map +1 -1
  37. package/script/oas/example/Example.js +74 -1
  38. package/script/oas/header/Header.d.ts +217 -1
  39. package/script/oas/header/Header.d.ts.map +1 -1
  40. package/script/oas/header/Header.js +207 -1
  41. package/script/oas/info/Info.d.ts +72 -0
  42. package/script/oas/info/Info.d.ts.map +1 -1
  43. package/script/oas/info/Info.js +62 -0
  44. package/script/oas/mediaType/MediaType.d.ts +85 -0
  45. package/script/oas/mediaType/MediaType.d.ts.map +1 -1
  46. package/script/oas/mediaType/MediaType.js +77 -0
  47. package/script/oas/number/Number.d.ts +179 -1
  48. package/script/oas/number/Number.d.ts.map +1 -1
  49. package/script/oas/number/Number.js +161 -1
  50. package/script/oas/pathItem/PathItem.d.ts +92 -0
  51. package/script/oas/pathItem/PathItem.d.ts.map +1 -1
  52. package/script/oas/pathItem/PathItem.js +85 -0
  53. package/script/oas/requestBody/RequestBody.d.ts +264 -0
  54. package/script/oas/requestBody/RequestBody.d.ts.map +1 -1
  55. package/script/oas/requestBody/RequestBody.js +257 -0
  56. package/script/oas/response/Response.d.ts +190 -0
  57. package/script/oas/response/Response.d.ts.map +1 -1
  58. package/script/oas/response/Response.js +183 -0
  59. package/script/oas/void/Void.d.ts +130 -3
  60. package/script/oas/void/Void.d.ts.map +1 -1
  61. package/script/oas/void/Void.js +125 -3
@@ -1,9 +1,73 @@
1
1
  import type { OasOperation } from '../oas/operation/Operation.js';
2
2
  import type { Method } from '../types/Method.js';
3
+ /**
4
+ * Determines the endpoint type based on HTTP method.
5
+ *
6
+ * @param operation - The OpenAPI operation to analyze
7
+ * @returns 'query' for GET operations, 'mutation' for all others
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const getOp = new OasOperation({ method: 'get', path: '/users' });
12
+ * console.log(toEndpointType(getOp)); // 'query'
13
+ *
14
+ * const postOp = new OasOperation({ method: 'post', path: '/users' });
15
+ * console.log(toEndpointType(postOp)); // 'mutation'
16
+ * ```
17
+ */
3
18
  export declare const toEndpointType: (operation: OasOperation) => "query" | "mutation";
4
- /** generates endpoint name in the `camelCase{method}Api{path}` format */
19
+ /**
20
+ * Generates endpoint name in the `camelCase{method}Api{path}` format.
21
+ *
22
+ * @param operation - The OpenAPI operation
23
+ * @returns Camel-cased endpoint name
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const op = new OasOperation({ method: 'post', path: '/users/{id}/profile' });
28
+ * console.log(toEndpointName(op)); // 'createApiUsersIdProfile'
29
+ * ```
30
+ */
5
31
  export declare const toEndpointName: (operation: OasOperation) => string;
32
+ /**
33
+ * Generates response type name for an operation.
34
+ *
35
+ * @param operation - The OpenAPI operation
36
+ * @returns Response type name with 'Response' suffix
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const op = new OasOperation({ method: 'get', path: '/users' });
41
+ * console.log(toResponseName(op)); // 'getApiUsersResponse'
42
+ * ```
43
+ */
6
44
  export declare const toResponseName: (operation: OasOperation) => string;
45
+ /**
46
+ * Generates arguments type name for an operation.
47
+ *
48
+ * @param operation - The OpenAPI operation
49
+ * @returns Arguments type name with 'Args' suffix
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const op = new OasOperation({ method: 'put', path: '/users/{id}' });
54
+ * console.log(toArgsName(op)); // 'updateApiUsersIdArgs'
55
+ * ```
56
+ */
7
57
  export declare const toArgsName: (operation: OasOperation) => string;
58
+ /**
59
+ * Converts HTTP method to a descriptive verb.
60
+ *
61
+ * @param method - HTTP method
62
+ * @returns Descriptive verb for the method
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * console.log(toMethodVerb('post')); // 'Create'
67
+ * console.log(toMethodVerb('put')); // 'Update'
68
+ * console.log(toMethodVerb('get')); // 'get'
69
+ * console.log(toMethodVerb('delete')); // 'delete'
70
+ * ```
71
+ */
8
72
  export declare const toMethodVerb: (method: Method) => string;
9
73
  //# sourceMappingURL=naming.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/helpers/naming.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAGhD,eAAO,MAAM,cAAc,GAAI,WAAW,YAAY,KAAG,OAAO,GAAG,UAElE,CAAA;AAED,yEAAyE;AACzE,eAAO,MAAM,cAAc,GAAI,WAAW,YAAY,KAAG,MAMxD,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,WAAW,YAAY,KAAG,MAIxD,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,WAAW,YAAY,KAAG,MAIpD,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,MAK7C,CAAA"}
1
+ {"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/helpers/naming.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAGhD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,GAAI,WAAW,YAAY,KAAG,OAAO,GAAG,UAElE,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAAI,WAAW,YAAY,KAAG,MAMxD,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAAI,WAAW,YAAY,KAAG,MAIxD,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,GAAI,WAAW,YAAY,KAAG,MAIpD,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,MAK7C,CAAA"}
@@ -3,27 +3,91 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toMethodVerb = exports.toArgsName = exports.toResponseName = exports.toEndpointName = exports.toEndpointType = void 0;
4
4
  const lodash_es_1 = require("lodash-es");
5
5
  const ts_pattern_1 = require("ts-pattern");
6
+ /**
7
+ * Determines the endpoint type based on HTTP method.
8
+ *
9
+ * @param operation - The OpenAPI operation to analyze
10
+ * @returns 'query' for GET operations, 'mutation' for all others
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const getOp = new OasOperation({ method: 'get', path: '/users' });
15
+ * console.log(toEndpointType(getOp)); // 'query'
16
+ *
17
+ * const postOp = new OasOperation({ method: 'post', path: '/users' });
18
+ * console.log(toEndpointType(postOp)); // 'mutation'
19
+ * ```
20
+ */
6
21
  const toEndpointType = (operation) => {
7
22
  return operation.method === 'get' ? 'query' : 'mutation';
8
23
  };
9
24
  exports.toEndpointType = toEndpointType;
10
- /** generates endpoint name in the `camelCase{method}Api{path}` format */
25
+ /**
26
+ * Generates endpoint name in the `camelCase{method}Api{path}` format.
27
+ *
28
+ * @param operation - The OpenAPI operation
29
+ * @returns Camel-cased endpoint name
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const op = new OasOperation({ method: 'post', path: '/users/{id}/profile' });
34
+ * console.log(toEndpointName(op)); // 'createApiUsersIdProfile'
35
+ * ```
36
+ */
11
37
  const toEndpointName = (operation) => {
12
38
  const { path, method } = operation;
13
39
  const verb = (0, exports.toMethodVerb)(method);
14
40
  return (0, lodash_es_1.camelCase)(`${verb}Api${path}`);
15
41
  };
16
42
  exports.toEndpointName = toEndpointName;
43
+ /**
44
+ * Generates response type name for an operation.
45
+ *
46
+ * @param operation - The OpenAPI operation
47
+ * @returns Response type name with 'Response' suffix
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const op = new OasOperation({ method: 'get', path: '/users' });
52
+ * console.log(toResponseName(op)); // 'getApiUsersResponse'
53
+ * ```
54
+ */
17
55
  const toResponseName = (operation) => {
18
56
  const operationName = (0, exports.toEndpointName)(operation);
19
57
  return `${operationName}Response`;
20
58
  };
21
59
  exports.toResponseName = toResponseName;
60
+ /**
61
+ * Generates arguments type name for an operation.
62
+ *
63
+ * @param operation - The OpenAPI operation
64
+ * @returns Arguments type name with 'Args' suffix
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const op = new OasOperation({ method: 'put', path: '/users/{id}' });
69
+ * console.log(toArgsName(op)); // 'updateApiUsersIdArgs'
70
+ * ```
71
+ */
22
72
  const toArgsName = (operation) => {
23
73
  const operationName = (0, exports.toEndpointName)(operation);
24
74
  return `${operationName}Args`;
25
75
  };
26
76
  exports.toArgsName = toArgsName;
77
+ /**
78
+ * Converts HTTP method to a descriptive verb.
79
+ *
80
+ * @param method - HTTP method
81
+ * @returns Descriptive verb for the method
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * console.log(toMethodVerb('post')); // 'Create'
86
+ * console.log(toMethodVerb('put')); // 'Update'
87
+ * console.log(toMethodVerb('get')); // 'get'
88
+ * console.log(toMethodVerb('delete')); // 'delete'
89
+ * ```
90
+ */
27
91
  const toMethodVerb = (method) => {
28
92
  return (0, ts_pattern_1.match)(method)
29
93
  .with('post', () => 'Create')
@@ -1,13 +1,93 @@
1
1
  import type { OasRef } from '../ref/Ref.js';
2
2
  import type { ToJsonSchemaOptions } from '../schema/Schema.js';
3
3
  import type { OpenAPIV3 } from 'openapi-types';
4
+ /**
5
+ * Constructor fields for {@link OasExample}.
6
+ */
4
7
  export type ExampleFields = {
8
+ /** Short summary of the example */
5
9
  summary: string | undefined;
10
+ /** Longer description of the example */
6
11
  description: string | undefined;
12
+ /** The example value */
7
13
  value: unknown;
14
+ /** Custom extension fields (x-* properties) */
8
15
  extensionFields?: Record<string, unknown>;
9
16
  };
10
- /** Provides example data represented by schema */
17
+ /**
18
+ * Represents an Example Object in the OpenAPI Specification.
19
+ *
20
+ * The `OasExample` class provides sample data for parameters, request bodies,
21
+ * responses, and other components in an OpenAPI document. Examples are crucial
22
+ * for API documentation, testing, and helping developers understand expected
23
+ * data formats and structures.
24
+ *
25
+ * This class supports rich example definitions with metadata, making API
26
+ * documentation more informative and interactive for developers.
27
+ *
28
+ * ## Key Features
29
+ *
30
+ * - **Sample Data**: Concrete examples of API inputs and outputs
31
+ * - **Documentation**: Summary and description for context
32
+ * - **Type Flexibility**: Supports any data type as example values
33
+ * - **Reference Support**: Can be referenced from multiple locations
34
+ * - **Markdown Support**: Rich text descriptions with CommonMark
35
+ *
36
+ * @example Simple string example
37
+ * ```typescript
38
+ * import { OasExample } from '@skmtc/core';
39
+ *
40
+ * const nameExample = new OasExample({
41
+ * summary: 'Typical user name',
42
+ * description: 'A common first and last name combination',
43
+ * value: 'John Doe'
44
+ * });
45
+ * ```
46
+ *
47
+ * @example JSON object example
48
+ * ```typescript
49
+ * const userExample = new OasExample({
50
+ * summary: 'Complete user profile',
51
+ * description: 'Example user with all profile fields populated',
52
+ * value: {
53
+ * id: 12345,
54
+ * name: 'Jane Smith',
55
+ * email: 'jane.smith@example.com',
56
+ * active: true,
57
+ * createdAt: '2023-01-15T10:30:00Z'
58
+ * }
59
+ * });
60
+ * ```
61
+ *
62
+ * @example Array example with multiple items
63
+ * ```typescript
64
+ * const productsExample = new OasExample({
65
+ * summary: 'Product list sample',
66
+ * description: 'Typical response for product catalog endpoint',
67
+ * value: [
68
+ * { id: 1, name: 'Laptop', price: 999.99, category: 'Electronics' },
69
+ * { id: 2, name: 'Book', price: 19.99, category: 'Education' },
70
+ * { id: 3, name: 'Coffee Mug', price: 12.50, category: 'Home' }
71
+ * ]
72
+ * });
73
+ * ```
74
+ *
75
+ * @example Error response example
76
+ * ```typescript
77
+ * const errorExample = new OasExample({
78
+ * summary: 'Validation error',
79
+ * description: 'Response when request validation fails',
80
+ * value: {
81
+ * error: 'Validation failed',
82
+ * code: 'INVALID_INPUT',
83
+ * details: [
84
+ * { field: 'email', message: 'Invalid email format' },
85
+ * { field: 'age', message: 'Must be between 18 and 120' }
86
+ * ]
87
+ * }
88
+ * });
89
+ * ```
90
+ */
11
91
  export declare class OasExample {
12
92
  #private;
13
93
  /** Static identifier property for OasExample */
@@ -1 +1 @@
1
- {"version":3,"file":"Example.d.ts","sourceRoot":"","sources":["../../../src/oas/example/Example.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED,kDAAkD;AAClD,qBAAa,UAAU;;IACrB,gDAAgD;IAChD,OAAO,EAAE,SAAS,CAAY;gBAIlB,MAAM,EAAE,aAAa;IAIjC,+BAA+B;IAC/B,IAAI,OAAO,IAAI,MAAM,GAAG,SAAS,CAEhC;IAED,2EAA2E;IAC3E,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED,6BAA6B;IAC7B,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED,qCAAqC;IACrC,IAAI,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAEzD;IAED,4CAA4C;IAC5C,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC;IAIlC,qBAAqB;IACrB,OAAO,IAAI,UAAU;IAIrB,WAAW,IAAI,UAAU;IAIzB,YAAY,CAAC,QAAQ,EAAE,mBAAmB,GAAG,SAAS,CAAC,aAAa;CAOrE"}
1
+ {"version":3,"file":"Example.d.ts","sourceRoot":"","sources":["../../../src/oas/example/Example.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,mCAAmC;IACnC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,wCAAwC;IACxC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,wBAAwB;IACxB,KAAK,EAAE,OAAO,CAAA;IACd,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,qBAAa,UAAU;;IACrB,gDAAgD;IAChD,OAAO,EAAE,SAAS,CAAY;gBAIlB,MAAM,EAAE,aAAa;IAIjC,+BAA+B;IAC/B,IAAI,OAAO,IAAI,MAAM,GAAG,SAAS,CAEhC;IAED,2EAA2E;IAC3E,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED,6BAA6B;IAC7B,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED,qCAAqC;IACrC,IAAI,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAEzD;IAED,4CAA4C;IAC5C,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC;IAIlC,qBAAqB;IACrB,OAAO,IAAI,UAAU;IAIrB,WAAW,IAAI,UAAU;IAIzB,YAAY,CAAC,QAAQ,EAAE,mBAAmB,GAAG,SAAS,CAAC,aAAa;CAOrE"}
@@ -13,7 +13,80 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _OasExample_fields;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.OasExample = void 0;
16
- /** Provides example data represented by schema */
16
+ /**
17
+ * Represents an Example Object in the OpenAPI Specification.
18
+ *
19
+ * The `OasExample` class provides sample data for parameters, request bodies,
20
+ * responses, and other components in an OpenAPI document. Examples are crucial
21
+ * for API documentation, testing, and helping developers understand expected
22
+ * data formats and structures.
23
+ *
24
+ * This class supports rich example definitions with metadata, making API
25
+ * documentation more informative and interactive for developers.
26
+ *
27
+ * ## Key Features
28
+ *
29
+ * - **Sample Data**: Concrete examples of API inputs and outputs
30
+ * - **Documentation**: Summary and description for context
31
+ * - **Type Flexibility**: Supports any data type as example values
32
+ * - **Reference Support**: Can be referenced from multiple locations
33
+ * - **Markdown Support**: Rich text descriptions with CommonMark
34
+ *
35
+ * @example Simple string example
36
+ * ```typescript
37
+ * import { OasExample } from '@skmtc/core';
38
+ *
39
+ * const nameExample = new OasExample({
40
+ * summary: 'Typical user name',
41
+ * description: 'A common first and last name combination',
42
+ * value: 'John Doe'
43
+ * });
44
+ * ```
45
+ *
46
+ * @example JSON object example
47
+ * ```typescript
48
+ * const userExample = new OasExample({
49
+ * summary: 'Complete user profile',
50
+ * description: 'Example user with all profile fields populated',
51
+ * value: {
52
+ * id: 12345,
53
+ * name: 'Jane Smith',
54
+ * email: 'jane.smith@example.com',
55
+ * active: true,
56
+ * createdAt: '2023-01-15T10:30:00Z'
57
+ * }
58
+ * });
59
+ * ```
60
+ *
61
+ * @example Array example with multiple items
62
+ * ```typescript
63
+ * const productsExample = new OasExample({
64
+ * summary: 'Product list sample',
65
+ * description: 'Typical response for product catalog endpoint',
66
+ * value: [
67
+ * { id: 1, name: 'Laptop', price: 999.99, category: 'Electronics' },
68
+ * { id: 2, name: 'Book', price: 19.99, category: 'Education' },
69
+ * { id: 3, name: 'Coffee Mug', price: 12.50, category: 'Home' }
70
+ * ]
71
+ * });
72
+ * ```
73
+ *
74
+ * @example Error response example
75
+ * ```typescript
76
+ * const errorExample = new OasExample({
77
+ * summary: 'Validation error',
78
+ * description: 'Response when request validation fails',
79
+ * value: {
80
+ * error: 'Validation failed',
81
+ * code: 'INVALID_INPUT',
82
+ * details: [
83
+ * { field: 'email', message: 'Invalid email format' },
84
+ * { field: 'age', message: 'Must be between 18 and 120' }
85
+ * ]
86
+ * }
87
+ * });
88
+ * ```
89
+ */
17
90
  class OasExample {
18
91
  constructor(fields) {
19
92
  /** Static identifier property for OasExample */
@@ -4,16 +4,232 @@ import type { OasExample } from '../example/Example.js';
4
4
  import type { OasSchema } from '../schema/Schema.js';
5
5
  import type { ToJsonSchemaOptions } from '../schema/Schema.js';
6
6
  import type { OpenAPIV3 } from 'openapi-types';
7
+ /**
8
+ * Constructor fields for {@link OasHeader}.
9
+ */
7
10
  export type HeaderFields = {
11
+ /** A brief description of the header */
8
12
  description: string | undefined;
13
+ /** Whether the header is required */
9
14
  required: boolean | undefined;
15
+ /** Whether the header is deprecated */
10
16
  deprecated: boolean | undefined;
17
+ /** Schema defining the header's data type */
11
18
  schema: OasSchema | OasRef<'schema'> | undefined;
19
+ /** Example values for the header */
12
20
  examples: Record<string, OasExample | OasRef<'example'>> | undefined;
21
+ /** Content definitions for complex header values */
13
22
  content: Record<string, OasMediaType> | undefined;
23
+ /** Custom extension fields (x-* properties) */
14
24
  extensionFields?: Record<string, unknown>;
15
25
  };
16
- /** Describes a single header in the API */
26
+ /**
27
+ * Represents a Header Object in the OpenAPI Specification.
28
+ *
29
+ * The `OasHeader` class encapsulates the definition of a single HTTP header that
30
+ * can be sent with responses or expected in requests. Headers provide additional
31
+ * metadata about the HTTP message and can include authentication tokens, content
32
+ * information, pagination data, rate limiting details, and more.
33
+ *
34
+ * This class provides comprehensive support for header definitions with typed
35
+ * values, validation schemas, examples, and documentation.
36
+ *
37
+ * ## Key Features
38
+ *
39
+ * - **Schema Validation**: Typed header values through schema definitions
40
+ * - **Examples**: Multiple example values for documentation and testing
41
+ * - **Content Types**: Support for complex header values with media types
42
+ * - **Deprecation Support**: Mark headers as deprecated with proper warnings
43
+ * - **Required/Optional**: Control whether headers are mandatory
44
+ * - **Documentation**: Rich description support for API documentation
45
+ *
46
+ * @example Basic authentication header
47
+ * ```typescript
48
+ * import { OasHeader, OasString } from '@skmtc/core';
49
+ *
50
+ * const authHeader = new OasHeader({
51
+ * description: 'Bearer token for API authentication',
52
+ * required: true,
53
+ * schema: new OasString({
54
+ * pattern: '^Bearer [A-Za-z0-9+/=]+$',
55
+ * description: 'JWT bearer token'
56
+ * }),
57
+ * examples: {
58
+ * valid: new OasExample({
59
+ * summary: 'Valid bearer token',
60
+ * value: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
61
+ * })
62
+ * }
63
+ * });
64
+ * ```
65
+ *
66
+ * @example Pagination headers
67
+ * ```typescript
68
+ * const totalCountHeader = new OasHeader({
69
+ * description: 'Total number of items available',
70
+ * required: false,
71
+ * schema: new OasInteger({
72
+ * minimum: 0,
73
+ * description: 'Non-negative integer count'
74
+ * }),
75
+ * examples: {
76
+ * empty: new OasExample({ value: 0, description: 'No items' }),
77
+ * normal: new OasExample({ value: 150, description: 'Normal case' }),
78
+ * large: new OasExample({ value: 10000, description: 'Large dataset' })
79
+ * }
80
+ * });
81
+ *
82
+ * const linkHeader = new OasHeader({
83
+ * description: 'Pagination links (RFC 5988)',
84
+ * required: false,
85
+ * schema: new OasString({
86
+ * description: 'Comma-separated list of link relations'
87
+ * }),
88
+ * examples: {
89
+ * withNext: new OasExample({
90
+ * value: '</api/users?page=2>; rel="next", </api/users?page=10>; rel="last"'
91
+ * }),
92
+ * lastPage: new OasExample({
93
+ * value: '</api/users?page=9>; rel="prev", </api/users?page=1>; rel="first"'
94
+ * })
95
+ * }
96
+ * });
97
+ * ```
98
+ *
99
+ * @example Content type and encoding headers
100
+ * ```typescript
101
+ * const contentTypeHeader = new OasHeader({
102
+ * description: 'MIME type of the response content',
103
+ * required: true,
104
+ * schema: new OasString({
105
+ * enum: [
106
+ * 'application/json',
107
+ * 'application/xml',
108
+ * 'text/csv',
109
+ * 'application/pdf',
110
+ * 'application/octet-stream'
111
+ * ]
112
+ * }),
113
+ * examples: {
114
+ * json: new OasExample({ value: 'application/json' }),
115
+ * xml: new OasExample({ value: 'application/xml' }),
116
+ * csv: new OasExample({ value: 'text/csv' })
117
+ * }
118
+ * });
119
+ *
120
+ * const contentLengthHeader = new OasHeader({
121
+ * description: 'Size of the response body in bytes',
122
+ * required: false,
123
+ * schema: new OasInteger({
124
+ * minimum: 0,
125
+ * description: 'Content size in bytes'
126
+ * })
127
+ * });
128
+ * ```
129
+ *
130
+ * @example Rate limiting headers
131
+ * ```typescript
132
+ * const rateLimitHeader = new OasHeader({
133
+ * description: 'Number of requests remaining in the current window',
134
+ * required: false,
135
+ * schema: new OasInteger({
136
+ * minimum: 0,
137
+ * description: 'Remaining request count'
138
+ * }),
139
+ * examples: {
140
+ * available: new OasExample({ value: 95, description: '95 requests remaining' }),
141
+ * depleted: new OasExample({ value: 0, description: 'Rate limit reached' })
142
+ * }
143
+ * });
144
+ *
145
+ * const rateLimitResetHeader = new OasHeader({
146
+ * description: 'Unix timestamp when the rate limit window resets',
147
+ * required: false,
148
+ * schema: new OasInteger({
149
+ * minimum: 0,
150
+ * description: 'Unix timestamp in seconds'
151
+ * }),
152
+ * examples: {
153
+ * reset: new OasExample({
154
+ * value: 1634567890,
155
+ * description: 'Reset at 2021-10-18 12:31:30 UTC'
156
+ * })
157
+ * }
158
+ * });
159
+ * ```
160
+ *
161
+ * @example Custom application headers
162
+ * ```typescript
163
+ * const requestIdHeader = new OasHeader({
164
+ * description: 'Unique identifier for request tracing',
165
+ * required: false,
166
+ * schema: new OasString({
167
+ * format: 'uuid',
168
+ * description: 'UUID v4 request identifier'
169
+ * }),
170
+ * examples: {
171
+ * uuid: new OasExample({
172
+ * value: '123e4567-e89b-12d3-a456-426614174000',
173
+ * description: 'Request tracking ID'
174
+ * })
175
+ * }
176
+ * });
177
+ *
178
+ * const serverTimingHeader = new OasHeader({
179
+ * description: 'Server-side performance metrics',
180
+ * required: false,
181
+ * schema: new OasString({
182
+ * description: 'Server-Timing header format (RFC 8760)'
183
+ * }),
184
+ * examples: {
185
+ * timing: new OasExample({
186
+ * value: 'db;dur=53, app;dur=47.2',
187
+ * description: 'Database took 53ms, app logic 47.2ms'
188
+ * })
189
+ * }
190
+ * });
191
+ * ```
192
+ *
193
+ * @example Deprecated header
194
+ * ```typescript
195
+ * const deprecatedHeader = new OasHeader({
196
+ * description: 'Legacy API version header (deprecated)',
197
+ * required: false,
198
+ * deprecated: true,
199
+ * schema: new OasString({
200
+ * enum: ['v1', 'v2'],
201
+ * description: 'Use Accept or Content-Type header instead'
202
+ * }),
203
+ * examples: {
204
+ * legacy: new OasExample({
205
+ * value: 'v1',
206
+ * description: 'Legacy version (use Accept header instead)'
207
+ * })
208
+ * }
209
+ * });
210
+ * ```
211
+ *
212
+ * @example Using in response definitions
213
+ * ```typescript
214
+ * const successResponse = new OasResponse({
215
+ * description: 'Paginated user list',
216
+ * headers: {
217
+ * 'X-Total-Count': totalCountHeader,
218
+ * 'Link': linkHeader,
219
+ * 'X-Rate-Limit-Remaining': rateLimitHeader,
220
+ * 'X-Rate-Limit-Reset': rateLimitResetHeader,
221
+ * 'X-Request-ID': requestIdHeader
222
+ * },
223
+ * content: {
224
+ * 'application/json': new OasMediaType({
225
+ * schema: new OasArray({
226
+ * items: new OasRef({ $ref: '#/components/schemas/User' })
227
+ * })
228
+ * })
229
+ * }
230
+ * });
231
+ * ```
232
+ */
17
233
  export declare class OasHeader {
18
234
  #private;
19
235
  oasType: 'header';
@@ -1 +1 @@
1
- {"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../src/oas/header/Header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CA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