@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.
- package/esm/helpers/naming.d.ts +65 -1
- package/esm/helpers/naming.d.ts.map +1 -1
- package/esm/helpers/naming.js +65 -1
- package/esm/oas/example/Example.d.ts +81 -1
- package/esm/oas/example/Example.d.ts.map +1 -1
- package/esm/oas/example/Example.js +74 -1
- package/esm/oas/header/Header.d.ts +217 -1
- package/esm/oas/header/Header.d.ts.map +1 -1
- package/esm/oas/header/Header.js +207 -1
- package/esm/oas/info/Info.d.ts +72 -0
- package/esm/oas/info/Info.d.ts.map +1 -1
- package/esm/oas/info/Info.js +62 -0
- package/esm/oas/mediaType/MediaType.d.ts +85 -0
- package/esm/oas/mediaType/MediaType.d.ts.map +1 -1
- package/esm/oas/mediaType/MediaType.js +77 -0
- package/esm/oas/number/Number.d.ts +179 -1
- package/esm/oas/number/Number.d.ts.map +1 -1
- package/esm/oas/number/Number.js +161 -1
- package/esm/oas/pathItem/PathItem.d.ts +92 -0
- package/esm/oas/pathItem/PathItem.d.ts.map +1 -1
- package/esm/oas/pathItem/PathItem.js +85 -0
- package/esm/oas/requestBody/RequestBody.d.ts +264 -0
- package/esm/oas/requestBody/RequestBody.d.ts.map +1 -1
- package/esm/oas/requestBody/RequestBody.js +257 -0
- package/esm/oas/response/Response.d.ts +190 -0
- package/esm/oas/response/Response.d.ts.map +1 -1
- package/esm/oas/response/Response.js +183 -0
- package/esm/oas/void/Void.d.ts +130 -3
- package/esm/oas/void/Void.d.ts.map +1 -1
- package/esm/oas/void/Void.js +125 -3
- package/package.json +1 -1
- package/script/helpers/naming.d.ts +65 -1
- package/script/helpers/naming.d.ts.map +1 -1
- package/script/helpers/naming.js +65 -1
- package/script/oas/example/Example.d.ts +81 -1
- package/script/oas/example/Example.d.ts.map +1 -1
- package/script/oas/example/Example.js +74 -1
- package/script/oas/header/Header.d.ts +217 -1
- package/script/oas/header/Header.d.ts.map +1 -1
- package/script/oas/header/Header.js +207 -1
- package/script/oas/info/Info.d.ts +72 -0
- package/script/oas/info/Info.d.ts.map +1 -1
- package/script/oas/info/Info.js +62 -0
- package/script/oas/mediaType/MediaType.d.ts +85 -0
- package/script/oas/mediaType/MediaType.d.ts.map +1 -1
- package/script/oas/mediaType/MediaType.js +77 -0
- package/script/oas/number/Number.d.ts +179 -1
- package/script/oas/number/Number.d.ts.map +1 -1
- package/script/oas/number/Number.js +161 -1
- package/script/oas/pathItem/PathItem.d.ts +92 -0
- package/script/oas/pathItem/PathItem.d.ts.map +1 -1
- package/script/oas/pathItem/PathItem.js +85 -0
- package/script/oas/requestBody/RequestBody.d.ts +264 -0
- package/script/oas/requestBody/RequestBody.d.ts.map +1 -1
- package/script/oas/requestBody/RequestBody.js +257 -0
- package/script/oas/response/Response.d.ts +190 -0
- package/script/oas/response/Response.d.ts.map +1 -1
- package/script/oas/response/Response.js +183 -0
- package/script/oas/void/Void.d.ts +130 -3
- package/script/oas/void/Void.d.ts.map +1 -1
- package/script/oas/void/Void.js +125 -3
|
@@ -2,23 +2,201 @@ import "../../_dnt.polyfills.js";
|
|
|
2
2
|
import type { OasRef } from '../ref/Ref.js';
|
|
3
3
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
4
4
|
import type { ToJsonSchemaOptions } from '../schema/Schema.js';
|
|
5
|
+
/**
|
|
6
|
+
* Constructor fields for {@link OasNumber}.
|
|
7
|
+
*
|
|
8
|
+
* @template Nullable - Whether the number can be null (affects type unions)
|
|
9
|
+
*/
|
|
5
10
|
export type NumberFields<Nullable extends boolean | undefined> = {
|
|
11
|
+
/** A short summary of the number schema */
|
|
6
12
|
title?: string;
|
|
13
|
+
/** A description of the number schema */
|
|
7
14
|
description?: string;
|
|
15
|
+
/** Whether the number value can be null */
|
|
8
16
|
nullable?: Nullable;
|
|
17
|
+
/** Default value for the number (null allowed if Nullable is true) */
|
|
9
18
|
default?: Nullable extends true ? number | null | undefined : number | undefined;
|
|
19
|
+
/** Custom extension fields (x-* properties) */
|
|
10
20
|
extensionFields?: Record<string, unknown>;
|
|
21
|
+
/** Example value for the number (null allowed if Nullable is true) */
|
|
11
22
|
example?: Nullable extends true ? number | null | undefined : number | undefined;
|
|
23
|
+
/** Array of valid enum values for the number (null allowed if Nullable is true) */
|
|
12
24
|
enums?: Nullable extends true ? (number | null)[] | undefined : number[] | undefined;
|
|
25
|
+
/** The format of the number (float or double precision) */
|
|
13
26
|
format?: 'float' | 'double';
|
|
27
|
+
/** Value must be a multiple of this number */
|
|
14
28
|
multipleOf?: number;
|
|
29
|
+
/** Maximum value allowed (inclusive by default) */
|
|
15
30
|
maximum?: number;
|
|
31
|
+
/** Whether the maximum value is exclusive */
|
|
16
32
|
exclusiveMaximum?: boolean;
|
|
33
|
+
/** Minimum value allowed (inclusive by default) */
|
|
17
34
|
minimum?: number;
|
|
35
|
+
/** Whether the minimum value is exclusive */
|
|
18
36
|
exclusiveMinimum?: boolean;
|
|
19
37
|
};
|
|
20
38
|
/**
|
|
21
|
-
*
|
|
39
|
+
* Represents a number schema in the OpenAPI Specification.
|
|
40
|
+
*
|
|
41
|
+
* The `OasNumber` class handles floating-point numeric data types in OpenAPI schemas,
|
|
42
|
+
* supporting comprehensive validation constraints including ranges, precision formats,
|
|
43
|
+
* and mathematical constraints. This class provides type-safe number handling with
|
|
44
|
+
* optional null value support and extensive validation capabilities.
|
|
45
|
+
*
|
|
46
|
+
* ## Key Features
|
|
47
|
+
*
|
|
48
|
+
* - **Range Validation**: Minimum and maximum constraints with exclusive/inclusive options
|
|
49
|
+
* - **Precision Control**: Float and double format support for different precision needs
|
|
50
|
+
* - **Mathematical Constraints**: Multiple-of validation for specific numeric patterns
|
|
51
|
+
* - **Type Safety**: Generic nullable type support with proper TypeScript inference
|
|
52
|
+
* - **Enum Support**: Constrain numbers to specific allowed values
|
|
53
|
+
* - **Null Handling**: Optional null value support for nullable number types
|
|
54
|
+
*
|
|
55
|
+
* @template Nullable - Whether the number value itself can be null
|
|
56
|
+
*
|
|
57
|
+
* @example Basic number schema with range
|
|
58
|
+
* ```typescript
|
|
59
|
+
* import { OasNumber } from '@skmtc/core';
|
|
60
|
+
*
|
|
61
|
+
* const ageSchema = new OasNumber({
|
|
62
|
+
* title: 'Age',
|
|
63
|
+
* description: 'Person age in years',
|
|
64
|
+
* minimum: 0,
|
|
65
|
+
* maximum: 150,
|
|
66
|
+
* example: 25,
|
|
67
|
+
* default: 18
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // This represents: number (0 <= value <= 150)
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example Price with precision and constraints
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const priceSchema = new OasNumber({
|
|
76
|
+
* title: 'Product Price',
|
|
77
|
+
* description: 'Price in USD with cent precision',
|
|
78
|
+
* format: 'double',
|
|
79
|
+
* minimum: 0,
|
|
80
|
+
* exclusiveMinimum: true, // Must be > 0, not >= 0
|
|
81
|
+
* multipleOf: 0.01, // Must be in cents (e.g., 19.99, 10.50)
|
|
82
|
+
* example: 29.99
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* // This represents: number > 0, in multiples of 0.01
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @example Percentage with strict bounds
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const percentageSchema = new OasNumber({
|
|
91
|
+
* title: 'Completion Percentage',
|
|
92
|
+
* description: 'Task completion as a percentage',
|
|
93
|
+
* minimum: 0,
|
|
94
|
+
* maximum: 100,
|
|
95
|
+
* multipleOf: 0.1, // One decimal place precision
|
|
96
|
+
* example: 75.5,
|
|
97
|
+
* default: 0
|
|
98
|
+
* });
|
|
99
|
+
*
|
|
100
|
+
* // This represents: 0 <= value <= 100, in increments of 0.1
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @example Nullable rating system
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const ratingSchema = new OasNumber<true>({
|
|
106
|
+
* title: 'User Rating',
|
|
107
|
+
* description: 'Product rating from 1-5 stars, null if not rated',
|
|
108
|
+
* nullable: true,
|
|
109
|
+
* minimum: 1,
|
|
110
|
+
* maximum: 5,
|
|
111
|
+
* multipleOf: 0.5, // Allow half-star ratings
|
|
112
|
+
* enums: [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, null],
|
|
113
|
+
* example: 4.5,
|
|
114
|
+
* default: null
|
|
115
|
+
* });
|
|
116
|
+
*
|
|
117
|
+
* // This represents: (1 | 1.5 | 2 | 2.5 | 3 | 3.5 | 4 | 4.5 | 5) | null
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @example Scientific measurement with high precision
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const temperatureSchema = new OasNumber({
|
|
123
|
+
* title: 'Temperature',
|
|
124
|
+
* description: 'Temperature in Celsius with high precision',
|
|
125
|
+
* format: 'double',
|
|
126
|
+
* minimum: -273.15, // Absolute zero
|
|
127
|
+
* maximum: 1000,
|
|
128
|
+
* multipleOf: 0.001, // Millikelvin precision
|
|
129
|
+
* example: 23.456
|
|
130
|
+
* });
|
|
131
|
+
*
|
|
132
|
+
* // For scientific applications requiring high precision
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @example Currency with regional constraints
|
|
136
|
+
* ```typescript
|
|
137
|
+
* const currencySchema = new OasNumber({
|
|
138
|
+
* title: 'Amount',
|
|
139
|
+
* description: 'Transaction amount in major currency units',
|
|
140
|
+
* format: 'double',
|
|
141
|
+
* minimum: 0,
|
|
142
|
+
* maximum: 999999.99,
|
|
143
|
+
* multipleOf: 0.01,
|
|
144
|
+
* example: 1234.56
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* // Used in financial applications
|
|
148
|
+
* const transaction = new OasObject({
|
|
149
|
+
* properties: {
|
|
150
|
+
* amount: currencySchema,
|
|
151
|
+
* currency: new OasString({ enum: ['USD', 'EUR', 'GBP'] })
|
|
152
|
+
* }
|
|
153
|
+
* });
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @example Coordinate system
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const latitudeSchema = new OasNumber({
|
|
159
|
+
* title: 'Latitude',
|
|
160
|
+
* description: 'Geographic latitude coordinate',
|
|
161
|
+
* format: 'double',
|
|
162
|
+
* minimum: -90,
|
|
163
|
+
* maximum: 90,
|
|
164
|
+
* example: 40.7128
|
|
165
|
+
* });
|
|
166
|
+
*
|
|
167
|
+
* const longitudeSchema = new OasNumber({
|
|
168
|
+
* title: 'Longitude',
|
|
169
|
+
* description: 'Geographic longitude coordinate',
|
|
170
|
+
* format: 'double',
|
|
171
|
+
* minimum: -180,
|
|
172
|
+
* maximum: 180,
|
|
173
|
+
* example: -74.0060
|
|
174
|
+
* });
|
|
175
|
+
*
|
|
176
|
+
* // Used for location data
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* @example Probability and statistics
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const probabilitySchema = new OasNumber({
|
|
182
|
+
* title: 'Probability',
|
|
183
|
+
* description: 'Statistical probability value',
|
|
184
|
+
* minimum: 0,
|
|
185
|
+
* maximum: 1,
|
|
186
|
+
* exclusiveMaximum: false, // Can be exactly 1
|
|
187
|
+
* example: 0.75,
|
|
188
|
+
* default: 0.5
|
|
189
|
+
* });
|
|
190
|
+
*
|
|
191
|
+
* const confidenceSchema = new OasNumber({
|
|
192
|
+
* title: 'Confidence Level',
|
|
193
|
+
* description: 'Statistical confidence level as percentage',
|
|
194
|
+
* minimum: 0,
|
|
195
|
+
* maximum: 100,
|
|
196
|
+
* enums: [90, 95, 99], // Common confidence levels
|
|
197
|
+
* example: 95
|
|
198
|
+
* });
|
|
199
|
+
* ```
|
|
22
200
|
*/
|
|
23
201
|
export declare class OasNumber<Nullable extends boolean | undefined = boolean | undefined> {
|
|
24
202
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Number.d.ts","sourceRoot":"","sources":["../../../src/oas/number/Number.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"Number.d.ts","sourceRoot":"","sources":["../../../src/oas/number/Number.ts"],"names":[],"mappings":"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"}
|
|
@@ -3,7 +3,167 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OasNumber = void 0;
|
|
4
4
|
require("../../_dnt.polyfills.js");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Represents a number schema in the OpenAPI Specification.
|
|
7
|
+
*
|
|
8
|
+
* The `OasNumber` class handles floating-point numeric data types in OpenAPI schemas,
|
|
9
|
+
* supporting comprehensive validation constraints including ranges, precision formats,
|
|
10
|
+
* and mathematical constraints. This class provides type-safe number handling with
|
|
11
|
+
* optional null value support and extensive validation capabilities.
|
|
12
|
+
*
|
|
13
|
+
* ## Key Features
|
|
14
|
+
*
|
|
15
|
+
* - **Range Validation**: Minimum and maximum constraints with exclusive/inclusive options
|
|
16
|
+
* - **Precision Control**: Float and double format support for different precision needs
|
|
17
|
+
* - **Mathematical Constraints**: Multiple-of validation for specific numeric patterns
|
|
18
|
+
* - **Type Safety**: Generic nullable type support with proper TypeScript inference
|
|
19
|
+
* - **Enum Support**: Constrain numbers to specific allowed values
|
|
20
|
+
* - **Null Handling**: Optional null value support for nullable number types
|
|
21
|
+
*
|
|
22
|
+
* @template Nullable - Whether the number value itself can be null
|
|
23
|
+
*
|
|
24
|
+
* @example Basic number schema with range
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { OasNumber } from '@skmtc/core';
|
|
27
|
+
*
|
|
28
|
+
* const ageSchema = new OasNumber({
|
|
29
|
+
* title: 'Age',
|
|
30
|
+
* description: 'Person age in years',
|
|
31
|
+
* minimum: 0,
|
|
32
|
+
* maximum: 150,
|
|
33
|
+
* example: 25,
|
|
34
|
+
* default: 18
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // This represents: number (0 <= value <= 150)
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example Price with precision and constraints
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const priceSchema = new OasNumber({
|
|
43
|
+
* title: 'Product Price',
|
|
44
|
+
* description: 'Price in USD with cent precision',
|
|
45
|
+
* format: 'double',
|
|
46
|
+
* minimum: 0,
|
|
47
|
+
* exclusiveMinimum: true, // Must be > 0, not >= 0
|
|
48
|
+
* multipleOf: 0.01, // Must be in cents (e.g., 19.99, 10.50)
|
|
49
|
+
* example: 29.99
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // This represents: number > 0, in multiples of 0.01
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example Percentage with strict bounds
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const percentageSchema = new OasNumber({
|
|
58
|
+
* title: 'Completion Percentage',
|
|
59
|
+
* description: 'Task completion as a percentage',
|
|
60
|
+
* minimum: 0,
|
|
61
|
+
* maximum: 100,
|
|
62
|
+
* multipleOf: 0.1, // One decimal place precision
|
|
63
|
+
* example: 75.5,
|
|
64
|
+
* default: 0
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* // This represents: 0 <= value <= 100, in increments of 0.1
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example Nullable rating system
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const ratingSchema = new OasNumber<true>({
|
|
73
|
+
* title: 'User Rating',
|
|
74
|
+
* description: 'Product rating from 1-5 stars, null if not rated',
|
|
75
|
+
* nullable: true,
|
|
76
|
+
* minimum: 1,
|
|
77
|
+
* maximum: 5,
|
|
78
|
+
* multipleOf: 0.5, // Allow half-star ratings
|
|
79
|
+
* enums: [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, null],
|
|
80
|
+
* example: 4.5,
|
|
81
|
+
* default: null
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* // This represents: (1 | 1.5 | 2 | 2.5 | 3 | 3.5 | 4 | 4.5 | 5) | null
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @example Scientific measurement with high precision
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const temperatureSchema = new OasNumber({
|
|
90
|
+
* title: 'Temperature',
|
|
91
|
+
* description: 'Temperature in Celsius with high precision',
|
|
92
|
+
* format: 'double',
|
|
93
|
+
* minimum: -273.15, // Absolute zero
|
|
94
|
+
* maximum: 1000,
|
|
95
|
+
* multipleOf: 0.001, // Millikelvin precision
|
|
96
|
+
* example: 23.456
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* // For scientific applications requiring high precision
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @example Currency with regional constraints
|
|
103
|
+
* ```typescript
|
|
104
|
+
* const currencySchema = new OasNumber({
|
|
105
|
+
* title: 'Amount',
|
|
106
|
+
* description: 'Transaction amount in major currency units',
|
|
107
|
+
* format: 'double',
|
|
108
|
+
* minimum: 0,
|
|
109
|
+
* maximum: 999999.99,
|
|
110
|
+
* multipleOf: 0.01,
|
|
111
|
+
* example: 1234.56
|
|
112
|
+
* });
|
|
113
|
+
*
|
|
114
|
+
* // Used in financial applications
|
|
115
|
+
* const transaction = new OasObject({
|
|
116
|
+
* properties: {
|
|
117
|
+
* amount: currencySchema,
|
|
118
|
+
* currency: new OasString({ enum: ['USD', 'EUR', 'GBP'] })
|
|
119
|
+
* }
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @example Coordinate system
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const latitudeSchema = new OasNumber({
|
|
126
|
+
* title: 'Latitude',
|
|
127
|
+
* description: 'Geographic latitude coordinate',
|
|
128
|
+
* format: 'double',
|
|
129
|
+
* minimum: -90,
|
|
130
|
+
* maximum: 90,
|
|
131
|
+
* example: 40.7128
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* const longitudeSchema = new OasNumber({
|
|
135
|
+
* title: 'Longitude',
|
|
136
|
+
* description: 'Geographic longitude coordinate',
|
|
137
|
+
* format: 'double',
|
|
138
|
+
* minimum: -180,
|
|
139
|
+
* maximum: 180,
|
|
140
|
+
* example: -74.0060
|
|
141
|
+
* });
|
|
142
|
+
*
|
|
143
|
+
* // Used for location data
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @example Probability and statistics
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const probabilitySchema = new OasNumber({
|
|
149
|
+
* title: 'Probability',
|
|
150
|
+
* description: 'Statistical probability value',
|
|
151
|
+
* minimum: 0,
|
|
152
|
+
* maximum: 1,
|
|
153
|
+
* exclusiveMaximum: false, // Can be exactly 1
|
|
154
|
+
* example: 0.75,
|
|
155
|
+
* default: 0.5
|
|
156
|
+
* });
|
|
157
|
+
*
|
|
158
|
+
* const confidenceSchema = new OasNumber({
|
|
159
|
+
* title: 'Confidence Level',
|
|
160
|
+
* description: 'Statistical confidence level as percentage',
|
|
161
|
+
* minimum: 0,
|
|
162
|
+
* maximum: 100,
|
|
163
|
+
* enums: [90, 95, 99], // Common confidence levels
|
|
164
|
+
* example: 95
|
|
165
|
+
* });
|
|
166
|
+
* ```
|
|
7
167
|
*/
|
|
8
168
|
class OasNumber {
|
|
9
169
|
constructor(fields = {}) {
|
|
@@ -1,11 +1,103 @@
|
|
|
1
1
|
import type { OasParameter } from '../parameter/Parameter.js';
|
|
2
2
|
import type { OasRef } from '../ref/Ref.js';
|
|
3
|
+
/**
|
|
4
|
+
* Constructor fields for {@link OasPathItem}.
|
|
5
|
+
*/
|
|
3
6
|
export type PathItemFields = {
|
|
7
|
+
/** Optional summary for the path item */
|
|
4
8
|
summary?: string | undefined;
|
|
9
|
+
/** Optional description for the path item */
|
|
5
10
|
description?: string | undefined;
|
|
11
|
+
/** Parameters that are applicable for all operations on this path */
|
|
6
12
|
parameters?: (OasParameter | OasRef<'parameter'>)[] | undefined;
|
|
13
|
+
/** Custom extension fields (x-* properties) */
|
|
7
14
|
extensionFields?: Record<string, unknown>;
|
|
8
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Represents a Path Item Object in the OpenAPI Specification.
|
|
18
|
+
*
|
|
19
|
+
* The `OasPathItem` class describes operations available on a single API path.
|
|
20
|
+
* It serves as a container for HTTP operations (GET, POST, PUT, DELETE, etc.)
|
|
21
|
+
* and can define parameters that apply to all operations on the path.
|
|
22
|
+
*
|
|
23
|
+
* This class provides path-level configuration and shared parameters that
|
|
24
|
+
* reduce duplication across operations on the same endpoint.
|
|
25
|
+
*
|
|
26
|
+
* ## Key Features
|
|
27
|
+
*
|
|
28
|
+
* - **Operation Container**: Groups HTTP methods for a single path
|
|
29
|
+
* - **Shared Parameters**: Path-level parameters for all operations
|
|
30
|
+
* - **Documentation**: Summary and description for the path
|
|
31
|
+
* - **Extension Support**: Custom fields for additional metadata
|
|
32
|
+
* - **Parameter Inheritance**: Parameters shared across all operations
|
|
33
|
+
*
|
|
34
|
+
* @example Basic path item with shared parameters
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { OasPathItem, OasParameter, OasString } from '@skmtc/core';
|
|
37
|
+
*
|
|
38
|
+
* const userPathItem = new OasPathItem({
|
|
39
|
+
* summary: 'User operations',
|
|
40
|
+
* description: 'Operations for managing individual users',
|
|
41
|
+
* parameters: [
|
|
42
|
+
* new OasParameter({
|
|
43
|
+
* name: 'userId',
|
|
44
|
+
* in: 'path',
|
|
45
|
+
* required: true,
|
|
46
|
+
* schema: new OasString({ format: 'uuid' }),
|
|
47
|
+
* description: 'Unique identifier for the user'
|
|
48
|
+
* })
|
|
49
|
+
* ]
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example Path with common headers
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const apiPathItem = new OasPathItem({
|
|
56
|
+
* summary: 'API endpoint',
|
|
57
|
+
* description: 'Authenticated endpoint requiring API key',
|
|
58
|
+
* parameters: [
|
|
59
|
+
* new OasParameter({
|
|
60
|
+
* name: 'Authorization',
|
|
61
|
+
* in: 'header',
|
|
62
|
+
* required: true,
|
|
63
|
+
* schema: new OasString({ pattern: '^Bearer .+$' }),
|
|
64
|
+
* description: 'Bearer token for authentication'
|
|
65
|
+
* }),
|
|
66
|
+
* new OasParameter({
|
|
67
|
+
* name: 'Accept-Version',
|
|
68
|
+
* in: 'header',
|
|
69
|
+
* required: false,
|
|
70
|
+
* schema: new OasString({ enum: ['v1', 'v2'] }),
|
|
71
|
+
* description: 'API version preference'
|
|
72
|
+
* })
|
|
73
|
+
* ]
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @example RESTful resource path
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const resourcePathItem = new OasPathItem({
|
|
80
|
+
* summary: 'Product resource',
|
|
81
|
+
* description: 'CRUD operations for product management',
|
|
82
|
+
* parameters: [
|
|
83
|
+
* new OasParameter({
|
|
84
|
+
* name: 'productId',
|
|
85
|
+
* in: 'path',
|
|
86
|
+
* required: true,
|
|
87
|
+
* schema: new OasInteger({ minimum: 1 }),
|
|
88
|
+
* description: 'Product identifier'
|
|
89
|
+
* }),
|
|
90
|
+
* new OasParameter({
|
|
91
|
+
* name: 'include',
|
|
92
|
+
* in: 'query',
|
|
93
|
+
* required: false,
|
|
94
|
+
* schema: new OasString({ enum: ['details', 'reviews', 'images'] }),
|
|
95
|
+
* description: 'Additional data to include in response'
|
|
96
|
+
* })
|
|
97
|
+
* ]
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
9
101
|
export declare class OasPathItem {
|
|
10
102
|
oasType: 'pathItem';
|
|
11
103
|
summary: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathItem.d.ts","sourceRoot":"","sources":["../../../src/oas/pathItem/PathItem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,UAAU,CAAC,EAAE,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,SAAS,CAAA;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED,qBAAa,WAAW;IACtB,OAAO,EAAE,UAAU,CAAa;IAChC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,UAAU,EAAE,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,SAAS,CAAA;IAC9D,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;gBAExC,MAAM,GAAE,cAAmB;CAMxC"}
|
|
1
|
+
{"version":3,"file":"PathItem.d.ts","sourceRoot":"","sources":["../../../src/oas/pathItem/PathItem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,qEAAqE;IACrE,UAAU,CAAC,EAAE,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,SAAS,CAAA;IAC/D,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AACH,qBAAa,WAAW;IACtB,OAAO,EAAE,UAAU,CAAa;IAChC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,UAAU,EAAE,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,SAAS,CAAA;IAC9D,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;gBAExC,MAAM,GAAE,cAAmB;CAMxC"}
|
|
@@ -1,6 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OasPathItem = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Represents a Path Item Object in the OpenAPI Specification.
|
|
6
|
+
*
|
|
7
|
+
* The `OasPathItem` class describes operations available on a single API path.
|
|
8
|
+
* It serves as a container for HTTP operations (GET, POST, PUT, DELETE, etc.)
|
|
9
|
+
* and can define parameters that apply to all operations on the path.
|
|
10
|
+
*
|
|
11
|
+
* This class provides path-level configuration and shared parameters that
|
|
12
|
+
* reduce duplication across operations on the same endpoint.
|
|
13
|
+
*
|
|
14
|
+
* ## Key Features
|
|
15
|
+
*
|
|
16
|
+
* - **Operation Container**: Groups HTTP methods for a single path
|
|
17
|
+
* - **Shared Parameters**: Path-level parameters for all operations
|
|
18
|
+
* - **Documentation**: Summary and description for the path
|
|
19
|
+
* - **Extension Support**: Custom fields for additional metadata
|
|
20
|
+
* - **Parameter Inheritance**: Parameters shared across all operations
|
|
21
|
+
*
|
|
22
|
+
* @example Basic path item with shared parameters
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { OasPathItem, OasParameter, OasString } from '@skmtc/core';
|
|
25
|
+
*
|
|
26
|
+
* const userPathItem = new OasPathItem({
|
|
27
|
+
* summary: 'User operations',
|
|
28
|
+
* description: 'Operations for managing individual users',
|
|
29
|
+
* parameters: [
|
|
30
|
+
* new OasParameter({
|
|
31
|
+
* name: 'userId',
|
|
32
|
+
* in: 'path',
|
|
33
|
+
* required: true,
|
|
34
|
+
* schema: new OasString({ format: 'uuid' }),
|
|
35
|
+
* description: 'Unique identifier for the user'
|
|
36
|
+
* })
|
|
37
|
+
* ]
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example Path with common headers
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const apiPathItem = new OasPathItem({
|
|
44
|
+
* summary: 'API endpoint',
|
|
45
|
+
* description: 'Authenticated endpoint requiring API key',
|
|
46
|
+
* parameters: [
|
|
47
|
+
* new OasParameter({
|
|
48
|
+
* name: 'Authorization',
|
|
49
|
+
* in: 'header',
|
|
50
|
+
* required: true,
|
|
51
|
+
* schema: new OasString({ pattern: '^Bearer .+$' }),
|
|
52
|
+
* description: 'Bearer token for authentication'
|
|
53
|
+
* }),
|
|
54
|
+
* new OasParameter({
|
|
55
|
+
* name: 'Accept-Version',
|
|
56
|
+
* in: 'header',
|
|
57
|
+
* required: false,
|
|
58
|
+
* schema: new OasString({ enum: ['v1', 'v2'] }),
|
|
59
|
+
* description: 'API version preference'
|
|
60
|
+
* })
|
|
61
|
+
* ]
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @example RESTful resource path
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const resourcePathItem = new OasPathItem({
|
|
68
|
+
* summary: 'Product resource',
|
|
69
|
+
* description: 'CRUD operations for product management',
|
|
70
|
+
* parameters: [
|
|
71
|
+
* new OasParameter({
|
|
72
|
+
* name: 'productId',
|
|
73
|
+
* in: 'path',
|
|
74
|
+
* required: true,
|
|
75
|
+
* schema: new OasInteger({ minimum: 1 }),
|
|
76
|
+
* description: 'Product identifier'
|
|
77
|
+
* }),
|
|
78
|
+
* new OasParameter({
|
|
79
|
+
* name: 'include',
|
|
80
|
+
* in: 'query',
|
|
81
|
+
* required: false,
|
|
82
|
+
* schema: new OasString({ enum: ['details', 'reviews', 'images'] }),
|
|
83
|
+
* description: 'Additional data to include in response'
|
|
84
|
+
* })
|
|
85
|
+
* ]
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
4
89
|
class OasPathItem {
|
|
5
90
|
constructor(fields = {}) {
|
|
6
91
|
Object.defineProperty(this, "oasType", {
|