@skmtc/core 0.0.803 → 0.0.804
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/oas/ref/ref-types.d.ts +48 -0
- package/esm/oas/ref/ref-types.d.ts.map +1 -1
- package/esm/oas/ref/ref-types.js +18 -0
- package/esm/oas/server/Server.d.ts +72 -0
- package/esm/oas/server/Server.d.ts.map +1 -1
- package/esm/oas/server/Server.js +66 -0
- package/package.json +1 -1
- package/script/oas/ref/ref-types.d.ts +48 -0
- package/script/oas/ref/ref-types.d.ts.map +1 -1
- package/script/oas/ref/ref-types.js +18 -0
- package/script/oas/server/Server.d.ts +72 -0
- package/script/oas/server/Server.d.ts.map +1 -1
- package/script/oas/server/Server.js +66 -0
|
@@ -65,6 +65,12 @@ export type OasParameterRefData = {
|
|
|
65
65
|
* Valibot schema for validating parameter reference data.
|
|
66
66
|
*/
|
|
67
67
|
export declare const oasParameterRefData: v.GenericSchema<OasParameterRefData>;
|
|
68
|
+
/**
|
|
69
|
+
* Data type for OpenAPI example reference objects.
|
|
70
|
+
*
|
|
71
|
+
* Represents $ref references to example objects in OpenAPI documents,
|
|
72
|
+
* enabling example reuse across multiple schema definitions and operations.
|
|
73
|
+
*/
|
|
68
74
|
export type OasExampleRefData = {
|
|
69
75
|
oasType: 'ref';
|
|
70
76
|
refType: 'example';
|
|
@@ -72,7 +78,16 @@ export type OasExampleRefData = {
|
|
|
72
78
|
summary?: string;
|
|
73
79
|
description?: string;
|
|
74
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Valibot schema for validating example reference data.
|
|
83
|
+
*/
|
|
75
84
|
export declare const oasExampleRefData: v.GenericSchema<OasExampleRefData>;
|
|
85
|
+
/**
|
|
86
|
+
* Data type for OpenAPI request body reference objects.
|
|
87
|
+
*
|
|
88
|
+
* Represents $ref references to request body objects in OpenAPI documents,
|
|
89
|
+
* allowing request body definitions to be reused across operations.
|
|
90
|
+
*/
|
|
76
91
|
export type OasRequestBodyRefData = {
|
|
77
92
|
oasType: 'ref';
|
|
78
93
|
refType: 'requestBody';
|
|
@@ -80,7 +95,16 @@ export type OasRequestBodyRefData = {
|
|
|
80
95
|
summary?: string;
|
|
81
96
|
description?: string;
|
|
82
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* Valibot schema for validating request body reference data.
|
|
100
|
+
*/
|
|
83
101
|
export declare const oasRequestBodyRefData: v.GenericSchema<OasRequestBodyRefData>;
|
|
102
|
+
/**
|
|
103
|
+
* Data type for OpenAPI header reference objects.
|
|
104
|
+
*
|
|
105
|
+
* Represents $ref references to header objects in OpenAPI documents,
|
|
106
|
+
* enabling header definition reuse across operations and responses.
|
|
107
|
+
*/
|
|
84
108
|
export type OasHeaderRefData = {
|
|
85
109
|
oasType: 'ref';
|
|
86
110
|
refType: 'header';
|
|
@@ -88,13 +112,37 @@ export type OasHeaderRefData = {
|
|
|
88
112
|
summary?: string;
|
|
89
113
|
description?: string;
|
|
90
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* Valibot schema for validating header reference data.
|
|
117
|
+
*/
|
|
91
118
|
export declare const oasHeaderRefData: v.GenericSchema<OasHeaderRefData>;
|
|
119
|
+
/**
|
|
120
|
+
* Data type for OpenAPI security scheme reference objects.
|
|
121
|
+
*
|
|
122
|
+
* Represents $ref references to security scheme objects in OpenAPI documents,
|
|
123
|
+
* allowing security scheme definitions to be reused across operations.
|
|
124
|
+
*/
|
|
92
125
|
export type OasSecuritySchemeRefData = {
|
|
93
126
|
oasType: 'ref';
|
|
94
127
|
refType: 'securityScheme';
|
|
95
128
|
$ref: string;
|
|
96
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* Valibot schema for validating security scheme reference data.
|
|
132
|
+
*/
|
|
97
133
|
export declare const oasSecuritySchemeRefData: v.GenericSchema<OasSecuritySchemeRefData>;
|
|
134
|
+
/**
|
|
135
|
+
* Union type representing all possible OpenAPI reference data types.
|
|
136
|
+
*
|
|
137
|
+
* Encompasses all supported reference types in the OpenAPI specification,
|
|
138
|
+
* providing type-safe handling of references to various component types.
|
|
139
|
+
*/
|
|
98
140
|
export type OasRefData = OasSchemaRefData | OasResponseRefData | OasParameterRefData | OasExampleRefData | OasRequestBodyRefData | OasHeaderRefData | OasSecuritySchemeRefData;
|
|
141
|
+
/**
|
|
142
|
+
* Valibot schema for validating any OpenAPI reference data.
|
|
143
|
+
*
|
|
144
|
+
* Union schema that validates all supported reference types,
|
|
145
|
+
* ensuring type safety across the entire reference system.
|
|
146
|
+
*/
|
|
99
147
|
export declare const oasRefData: v.GenericSchema<OasRefData>;
|
|
100
148
|
//# sourceMappingURL=ref-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref-types.d.ts","sourceRoot":"","sources":["../../../src/oas/ref/ref-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gDAAgD;IAChD,OAAO,EAAE,KAAK,CAAA;IACd,0CAA0C;IAC1C,OAAO,EAAE,QAAQ,CAAA;IACjB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAA;IACZ,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,aAAa,CAAC,gBAAgB,CAM7D,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gDAAgD;IAChD,OAAO,EAAE,KAAK,CAAA;IACd,0CAA0C;IAC1C,OAAO,EAAE,UAAU,CAAA;IACnB,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAA;IACZ,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CA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M,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,KAAK,CAAA;IACd,OAAO,EAAE,QAAQ,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,aAAa,CAAC,gBAAgB,CAM7D,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,KAAK,CAAA;IACd,OAAO,EAAE,gBAAgB,CAAA;IACzB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,CAAC,CAAC,aAAa,CAAC,wBAAwB,CAI7E,CAAA;AAUF;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB,gBAAgB,GAChB,kBAAkB,GAClB,mBAAmB,GACnB,iBAAiB,GACjB,qBAAqB,GACrB,gBAAgB,GAChB,wBAAwB,CAAA;AAG5B;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,aAAa,CAAC,UAAU,CASjD,CAAA"}
|
package/esm/oas/ref/ref-types.js
CHANGED
|
@@ -30,6 +30,9 @@ export const oasParameterRefData = v.object({
|
|
|
30
30
|
summary: v.optional(v.string()),
|
|
31
31
|
description: v.optional(markdown)
|
|
32
32
|
});
|
|
33
|
+
/**
|
|
34
|
+
* Valibot schema for validating example reference data.
|
|
35
|
+
*/
|
|
33
36
|
export const oasExampleRefData = v.object({
|
|
34
37
|
oasType: v.literal('ref'),
|
|
35
38
|
refType: v.literal('example'),
|
|
@@ -37,6 +40,9 @@ export const oasExampleRefData = v.object({
|
|
|
37
40
|
summary: v.optional(v.string()),
|
|
38
41
|
description: v.optional(markdown)
|
|
39
42
|
});
|
|
43
|
+
/**
|
|
44
|
+
* Valibot schema for validating request body reference data.
|
|
45
|
+
*/
|
|
40
46
|
export const oasRequestBodyRefData = v.object({
|
|
41
47
|
oasType: v.literal('ref'),
|
|
42
48
|
refType: v.literal('requestBody'),
|
|
@@ -44,6 +50,9 @@ export const oasRequestBodyRefData = v.object({
|
|
|
44
50
|
summary: v.optional(v.string()),
|
|
45
51
|
description: v.optional(markdown)
|
|
46
52
|
});
|
|
53
|
+
/**
|
|
54
|
+
* Valibot schema for validating header reference data.
|
|
55
|
+
*/
|
|
47
56
|
export const oasHeaderRefData = v.object({
|
|
48
57
|
oasType: v.literal('ref'),
|
|
49
58
|
refType: v.literal('header'),
|
|
@@ -51,12 +60,21 @@ export const oasHeaderRefData = v.object({
|
|
|
51
60
|
summary: v.optional(v.string()),
|
|
52
61
|
description: v.optional(markdown)
|
|
53
62
|
});
|
|
63
|
+
/**
|
|
64
|
+
* Valibot schema for validating security scheme reference data.
|
|
65
|
+
*/
|
|
54
66
|
export const oasSecuritySchemeRefData = v.object({
|
|
55
67
|
oasType: v.literal('ref'),
|
|
56
68
|
refType: v.literal('securityScheme'),
|
|
57
69
|
$ref: v.string()
|
|
58
70
|
});
|
|
59
71
|
// OasPathItemRefData
|
|
72
|
+
/**
|
|
73
|
+
* Valibot schema for validating any OpenAPI reference data.
|
|
74
|
+
*
|
|
75
|
+
* Union schema that validates all supported reference types,
|
|
76
|
+
* ensuring type safety across the entire reference system.
|
|
77
|
+
*/
|
|
60
78
|
export const oasRefData = v.union([
|
|
61
79
|
oasSchemaRefData,
|
|
62
80
|
oasResponseRefData,
|
|
@@ -2,22 +2,94 @@ import "../../_dnt.polyfills.js";
|
|
|
2
2
|
import type { ToJsonSchemaOptions } from '../schema/Schema.js';
|
|
3
3
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
4
4
|
import type { OasServerVariable } from '../serverVariable/ServerVariable.js';
|
|
5
|
+
/**
|
|
6
|
+
* Constructor fields for {@link OasServer}.
|
|
7
|
+
*
|
|
8
|
+
* Defines the configuration options available when creating server instances,
|
|
9
|
+
* including URL, description, variables, and extension fields.
|
|
10
|
+
*/
|
|
5
11
|
export type ServerFields = {
|
|
6
12
|
description?: string | undefined;
|
|
7
13
|
url: string;
|
|
8
14
|
variables?: Record<string, OasServerVariable> | undefined;
|
|
9
15
|
extensionFields?: Record<string, unknown>;
|
|
10
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Represents a Server Object in the OpenAPI Specification.
|
|
19
|
+
*
|
|
20
|
+
* The `OasServer` class encapsulates server connectivity information, including
|
|
21
|
+
* the server URL, optional description, and variable definitions for URL templating.
|
|
22
|
+
* Servers are used to specify different environments (development, staging, production)
|
|
23
|
+
* or different API versions that clients can connect to.
|
|
24
|
+
*
|
|
25
|
+
* @example Basic server
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const server = new OasServer({
|
|
28
|
+
* url: 'https://api.example.com/v1',
|
|
29
|
+
* description: 'Production API server'
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example Server with variables
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const server = new OasServer({
|
|
36
|
+
* url: 'https://{environment}.example.com/{version}',
|
|
37
|
+
* description: 'Configurable API server',
|
|
38
|
+
* variables: {
|
|
39
|
+
* environment: new OasServerVariable({
|
|
40
|
+
* enum: ['api', 'staging', 'dev'],
|
|
41
|
+
* default: 'api',
|
|
42
|
+
* description: 'API environment'
|
|
43
|
+
* }),
|
|
44
|
+
* version: new OasServerVariable({
|
|
45
|
+
* default: 'v1',
|
|
46
|
+
* description: 'API version'
|
|
47
|
+
* })
|
|
48
|
+
* }
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
11
52
|
export declare class OasServer {
|
|
53
|
+
/** Type identifier for this OAS server */
|
|
12
54
|
oasType: 'server';
|
|
55
|
+
/** Human-readable description of the server */
|
|
13
56
|
description: string | undefined;
|
|
57
|
+
/** Server URL with optional variable templating */
|
|
14
58
|
url: string;
|
|
59
|
+
/** Variable definitions for URL templating */
|
|
15
60
|
variables: Record<string, OasServerVariable> | undefined;
|
|
61
|
+
/** Custom extension fields (x-* properties) */
|
|
16
62
|
extensionFields: Record<string, unknown> | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a new OasServer instance.
|
|
65
|
+
*
|
|
66
|
+
* @param fields - Server configuration including URL, description, and variables
|
|
67
|
+
*/
|
|
17
68
|
constructor(fields: ServerFields);
|
|
69
|
+
/**
|
|
70
|
+
* Determines if this server is a reference object.
|
|
71
|
+
*
|
|
72
|
+
* @returns Always false since servers are not reference objects in OpenAPI
|
|
73
|
+
*/
|
|
18
74
|
isRef(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Resolves this server object.
|
|
77
|
+
*
|
|
78
|
+
* @returns The server instance itself since it's already a concrete object
|
|
79
|
+
*/
|
|
19
80
|
resolve(): OasServer;
|
|
81
|
+
/**
|
|
82
|
+
* Resolves this server object one level.
|
|
83
|
+
*
|
|
84
|
+
* @returns The server instance itself since it's already a concrete object
|
|
85
|
+
*/
|
|
20
86
|
resolveOnce(): OasServer;
|
|
87
|
+
/**
|
|
88
|
+
* Converts this OAS server to an OpenAPI v3 JSON schema representation.
|
|
89
|
+
*
|
|
90
|
+
* @param _options - Conversion options (currently unused for server objects)
|
|
91
|
+
* @returns OpenAPI v3 server object with URL, description, and variables
|
|
92
|
+
*/
|
|
21
93
|
toJsonSchema(_options: ToJsonSchemaOptions): OpenAPIV3.ServerObject;
|
|
22
94
|
}
|
|
23
95
|
//# sourceMappingURL=Server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../../src/oas/server/Server.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qC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AW;IAC5B,+CAA+C;IAC/C,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAA;IACX,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAAS,CAAA;IACxD,+CAA+C;IAC/C,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;IACpD;;;;OAIG;gBACS,MAAM,EAAE,YAAY;IAOhC;;;;OAIG;IACH,KAAK,IAAI,OAAO;IAIhB;;;;OAIG;IACH,OAAO,IAAI,SAAS;IAIpB;;;;OAIG;IACH,WAAW,IAAI,SAAS;IAIxB;;;;;OAKG;IACH,YAAY,CAAC,QAAQ,EAAE,mBAAmB,GAAG,SAAS,CAAC,YAAY;CAOpE"}
|
package/esm/oas/server/Server.js
CHANGED
|
@@ -1,30 +1,75 @@
|
|
|
1
1
|
import "../../_dnt.polyfills.js";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a Server Object in the OpenAPI Specification.
|
|
4
|
+
*
|
|
5
|
+
* The `OasServer` class encapsulates server connectivity information, including
|
|
6
|
+
* the server URL, optional description, and variable definitions for URL templating.
|
|
7
|
+
* Servers are used to specify different environments (development, staging, production)
|
|
8
|
+
* or different API versions that clients can connect to.
|
|
9
|
+
*
|
|
10
|
+
* @example Basic server
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const server = new OasServer({
|
|
13
|
+
* url: 'https://api.example.com/v1',
|
|
14
|
+
* description: 'Production API server'
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example Server with variables
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const server = new OasServer({
|
|
21
|
+
* url: 'https://{environment}.example.com/{version}',
|
|
22
|
+
* description: 'Configurable API server',
|
|
23
|
+
* variables: {
|
|
24
|
+
* environment: new OasServerVariable({
|
|
25
|
+
* enum: ['api', 'staging', 'dev'],
|
|
26
|
+
* default: 'api',
|
|
27
|
+
* description: 'API environment'
|
|
28
|
+
* }),
|
|
29
|
+
* version: new OasServerVariable({
|
|
30
|
+
* default: 'v1',
|
|
31
|
+
* description: 'API version'
|
|
32
|
+
* })
|
|
33
|
+
* }
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
2
37
|
export class OasServer {
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new OasServer instance.
|
|
40
|
+
*
|
|
41
|
+
* @param fields - Server configuration including URL, description, and variables
|
|
42
|
+
*/
|
|
3
43
|
constructor(fields) {
|
|
44
|
+
/** Type identifier for this OAS server */
|
|
4
45
|
Object.defineProperty(this, "oasType", {
|
|
5
46
|
enumerable: true,
|
|
6
47
|
configurable: true,
|
|
7
48
|
writable: true,
|
|
8
49
|
value: 'server'
|
|
9
50
|
});
|
|
51
|
+
/** Human-readable description of the server */
|
|
10
52
|
Object.defineProperty(this, "description", {
|
|
11
53
|
enumerable: true,
|
|
12
54
|
configurable: true,
|
|
13
55
|
writable: true,
|
|
14
56
|
value: void 0
|
|
15
57
|
});
|
|
58
|
+
/** Server URL with optional variable templating */
|
|
16
59
|
Object.defineProperty(this, "url", {
|
|
17
60
|
enumerable: true,
|
|
18
61
|
configurable: true,
|
|
19
62
|
writable: true,
|
|
20
63
|
value: void 0
|
|
21
64
|
});
|
|
65
|
+
/** Variable definitions for URL templating */
|
|
22
66
|
Object.defineProperty(this, "variables", {
|
|
23
67
|
enumerable: true,
|
|
24
68
|
configurable: true,
|
|
25
69
|
writable: true,
|
|
26
70
|
value: void 0
|
|
27
71
|
});
|
|
72
|
+
/** Custom extension fields (x-* properties) */
|
|
28
73
|
Object.defineProperty(this, "extensionFields", {
|
|
29
74
|
enumerable: true,
|
|
30
75
|
configurable: true,
|
|
@@ -36,15 +81,36 @@ export class OasServer {
|
|
|
36
81
|
this.variables = fields.variables;
|
|
37
82
|
this.extensionFields = fields.extensionFields;
|
|
38
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Determines if this server is a reference object.
|
|
86
|
+
*
|
|
87
|
+
* @returns Always false since servers are not reference objects in OpenAPI
|
|
88
|
+
*/
|
|
39
89
|
isRef() {
|
|
40
90
|
return false;
|
|
41
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Resolves this server object.
|
|
94
|
+
*
|
|
95
|
+
* @returns The server instance itself since it's already a concrete object
|
|
96
|
+
*/
|
|
42
97
|
resolve() {
|
|
43
98
|
return this;
|
|
44
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Resolves this server object one level.
|
|
102
|
+
*
|
|
103
|
+
* @returns The server instance itself since it's already a concrete object
|
|
104
|
+
*/
|
|
45
105
|
resolveOnce() {
|
|
46
106
|
return this;
|
|
47
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Converts this OAS server to an OpenAPI v3 JSON schema representation.
|
|
110
|
+
*
|
|
111
|
+
* @param _options - Conversion options (currently unused for server objects)
|
|
112
|
+
* @returns OpenAPI v3 server object with URL, description, and variables
|
|
113
|
+
*/
|
|
48
114
|
toJsonSchema(_options) {
|
|
49
115
|
return {
|
|
50
116
|
description: this.description,
|
package/package.json
CHANGED
|
@@ -65,6 +65,12 @@ export type OasParameterRefData = {
|
|
|
65
65
|
* Valibot schema for validating parameter reference data.
|
|
66
66
|
*/
|
|
67
67
|
export declare const oasParameterRefData: v.GenericSchema<OasParameterRefData>;
|
|
68
|
+
/**
|
|
69
|
+
* Data type for OpenAPI example reference objects.
|
|
70
|
+
*
|
|
71
|
+
* Represents $ref references to example objects in OpenAPI documents,
|
|
72
|
+
* enabling example reuse across multiple schema definitions and operations.
|
|
73
|
+
*/
|
|
68
74
|
export type OasExampleRefData = {
|
|
69
75
|
oasType: 'ref';
|
|
70
76
|
refType: 'example';
|
|
@@ -72,7 +78,16 @@ export type OasExampleRefData = {
|
|
|
72
78
|
summary?: string;
|
|
73
79
|
description?: string;
|
|
74
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Valibot schema for validating example reference data.
|
|
83
|
+
*/
|
|
75
84
|
export declare const oasExampleRefData: v.GenericSchema<OasExampleRefData>;
|
|
85
|
+
/**
|
|
86
|
+
* Data type for OpenAPI request body reference objects.
|
|
87
|
+
*
|
|
88
|
+
* Represents $ref references to request body objects in OpenAPI documents,
|
|
89
|
+
* allowing request body definitions to be reused across operations.
|
|
90
|
+
*/
|
|
76
91
|
export type OasRequestBodyRefData = {
|
|
77
92
|
oasType: 'ref';
|
|
78
93
|
refType: 'requestBody';
|
|
@@ -80,7 +95,16 @@ export type OasRequestBodyRefData = {
|
|
|
80
95
|
summary?: string;
|
|
81
96
|
description?: string;
|
|
82
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* Valibot schema for validating request body reference data.
|
|
100
|
+
*/
|
|
83
101
|
export declare const oasRequestBodyRefData: v.GenericSchema<OasRequestBodyRefData>;
|
|
102
|
+
/**
|
|
103
|
+
* Data type for OpenAPI header reference objects.
|
|
104
|
+
*
|
|
105
|
+
* Represents $ref references to header objects in OpenAPI documents,
|
|
106
|
+
* enabling header definition reuse across operations and responses.
|
|
107
|
+
*/
|
|
84
108
|
export type OasHeaderRefData = {
|
|
85
109
|
oasType: 'ref';
|
|
86
110
|
refType: 'header';
|
|
@@ -88,13 +112,37 @@ export type OasHeaderRefData = {
|
|
|
88
112
|
summary?: string;
|
|
89
113
|
description?: string;
|
|
90
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* Valibot schema for validating header reference data.
|
|
117
|
+
*/
|
|
91
118
|
export declare const oasHeaderRefData: v.GenericSchema<OasHeaderRefData>;
|
|
119
|
+
/**
|
|
120
|
+
* Data type for OpenAPI security scheme reference objects.
|
|
121
|
+
*
|
|
122
|
+
* Represents $ref references to security scheme objects in OpenAPI documents,
|
|
123
|
+
* allowing security scheme definitions to be reused across operations.
|
|
124
|
+
*/
|
|
92
125
|
export type OasSecuritySchemeRefData = {
|
|
93
126
|
oasType: 'ref';
|
|
94
127
|
refType: 'securityScheme';
|
|
95
128
|
$ref: string;
|
|
96
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* Valibot schema for validating security scheme reference data.
|
|
132
|
+
*/
|
|
97
133
|
export declare const oasSecuritySchemeRefData: v.GenericSchema<OasSecuritySchemeRefData>;
|
|
134
|
+
/**
|
|
135
|
+
* Union type representing all possible OpenAPI reference data types.
|
|
136
|
+
*
|
|
137
|
+
* Encompasses all supported reference types in the OpenAPI specification,
|
|
138
|
+
* providing type-safe handling of references to various component types.
|
|
139
|
+
*/
|
|
98
140
|
export type OasRefData = OasSchemaRefData | OasResponseRefData | OasParameterRefData | OasExampleRefData | OasRequestBodyRefData | OasHeaderRefData | OasSecuritySchemeRefData;
|
|
141
|
+
/**
|
|
142
|
+
* Valibot schema for validating any OpenAPI reference data.
|
|
143
|
+
*
|
|
144
|
+
* Union schema that validates all supported reference types,
|
|
145
|
+
* ensuring type safety across the entire reference system.
|
|
146
|
+
*/
|
|
99
147
|
export declare const oasRefData: v.GenericSchema<OasRefData>;
|
|
100
148
|
//# sourceMappingURL=ref-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref-types.d.ts","sourceRoot":"","sources":["../../../src/oas/ref/ref-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gDAAgD;IAChD,OAAO,EAAE,KAAK,CAAA;IACd,0CAA0C;IAC1C,OAAO,EAAE,QAAQ,CAAA;IACjB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAA;IACZ,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,aAAa,CAAC,gBAAgB,CAM7D,CAAA;AAEF;;;;;GAKG;AACH,MAAM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ACd,OAAO,EAAE,aAAa,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,aAAa,CAAC,qBAAqB,CAMvE,CAAA;AACF;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,KAAK,CAAA;IACd,OAAO,EAAE,QAAQ,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,aAAa,CAAC,gBAAgB,CAM7D,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,KAAK,CAAA;IACd,OAAO,EAAE,gBAAgB,CAAA;IACzB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,CAAC,CAAC,aAAa,CAAC,wBAAwB,CAI7E,CAAA;AAUF;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB,gBAAgB,GAChB,kBAAkB,GAClB,mBAAmB,GACnB,iBAAiB,GACjB,qBAAqB,GACrB,gBAAgB,GAChB,wBAAwB,CAAA;AAG5B;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,aAAa,CAAC,UAAU,CASjD,CAAA"}
|
|
@@ -66,6 +66,9 @@ exports.oasParameterRefData = v.object({
|
|
|
66
66
|
summary: v.optional(v.string()),
|
|
67
67
|
description: v.optional(markdown_types_js_1.markdown)
|
|
68
68
|
});
|
|
69
|
+
/**
|
|
70
|
+
* Valibot schema for validating example reference data.
|
|
71
|
+
*/
|
|
69
72
|
exports.oasExampleRefData = v.object({
|
|
70
73
|
oasType: v.literal('ref'),
|
|
71
74
|
refType: v.literal('example'),
|
|
@@ -73,6 +76,9 @@ exports.oasExampleRefData = v.object({
|
|
|
73
76
|
summary: v.optional(v.string()),
|
|
74
77
|
description: v.optional(markdown_types_js_1.markdown)
|
|
75
78
|
});
|
|
79
|
+
/**
|
|
80
|
+
* Valibot schema for validating request body reference data.
|
|
81
|
+
*/
|
|
76
82
|
exports.oasRequestBodyRefData = v.object({
|
|
77
83
|
oasType: v.literal('ref'),
|
|
78
84
|
refType: v.literal('requestBody'),
|
|
@@ -80,6 +86,9 @@ exports.oasRequestBodyRefData = v.object({
|
|
|
80
86
|
summary: v.optional(v.string()),
|
|
81
87
|
description: v.optional(markdown_types_js_1.markdown)
|
|
82
88
|
});
|
|
89
|
+
/**
|
|
90
|
+
* Valibot schema for validating header reference data.
|
|
91
|
+
*/
|
|
83
92
|
exports.oasHeaderRefData = v.object({
|
|
84
93
|
oasType: v.literal('ref'),
|
|
85
94
|
refType: v.literal('header'),
|
|
@@ -87,12 +96,21 @@ exports.oasHeaderRefData = v.object({
|
|
|
87
96
|
summary: v.optional(v.string()),
|
|
88
97
|
description: v.optional(markdown_types_js_1.markdown)
|
|
89
98
|
});
|
|
99
|
+
/**
|
|
100
|
+
* Valibot schema for validating security scheme reference data.
|
|
101
|
+
*/
|
|
90
102
|
exports.oasSecuritySchemeRefData = v.object({
|
|
91
103
|
oasType: v.literal('ref'),
|
|
92
104
|
refType: v.literal('securityScheme'),
|
|
93
105
|
$ref: v.string()
|
|
94
106
|
});
|
|
95
107
|
// OasPathItemRefData
|
|
108
|
+
/**
|
|
109
|
+
* Valibot schema for validating any OpenAPI reference data.
|
|
110
|
+
*
|
|
111
|
+
* Union schema that validates all supported reference types,
|
|
112
|
+
* ensuring type safety across the entire reference system.
|
|
113
|
+
*/
|
|
96
114
|
exports.oasRefData = v.union([
|
|
97
115
|
exports.oasSchemaRefData,
|
|
98
116
|
exports.oasResponseRefData,
|
|
@@ -2,22 +2,94 @@ import "../../_dnt.polyfills.js";
|
|
|
2
2
|
import type { ToJsonSchemaOptions } from '../schema/Schema.js';
|
|
3
3
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
4
4
|
import type { OasServerVariable } from '../serverVariable/ServerVariable.js';
|
|
5
|
+
/**
|
|
6
|
+
* Constructor fields for {@link OasServer}.
|
|
7
|
+
*
|
|
8
|
+
* Defines the configuration options available when creating server instances,
|
|
9
|
+
* including URL, description, variables, and extension fields.
|
|
10
|
+
*/
|
|
5
11
|
export type ServerFields = {
|
|
6
12
|
description?: string | undefined;
|
|
7
13
|
url: string;
|
|
8
14
|
variables?: Record<string, OasServerVariable> | undefined;
|
|
9
15
|
extensionFields?: Record<string, unknown>;
|
|
10
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Represents a Server Object in the OpenAPI Specification.
|
|
19
|
+
*
|
|
20
|
+
* The `OasServer` class encapsulates server connectivity information, including
|
|
21
|
+
* the server URL, optional description, and variable definitions for URL templating.
|
|
22
|
+
* Servers are used to specify different environments (development, staging, production)
|
|
23
|
+
* or different API versions that clients can connect to.
|
|
24
|
+
*
|
|
25
|
+
* @example Basic server
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const server = new OasServer({
|
|
28
|
+
* url: 'https://api.example.com/v1',
|
|
29
|
+
* description: 'Production API server'
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example Server with variables
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const server = new OasServer({
|
|
36
|
+
* url: 'https://{environment}.example.com/{version}',
|
|
37
|
+
* description: 'Configurable API server',
|
|
38
|
+
* variables: {
|
|
39
|
+
* environment: new OasServerVariable({
|
|
40
|
+
* enum: ['api', 'staging', 'dev'],
|
|
41
|
+
* default: 'api',
|
|
42
|
+
* description: 'API environment'
|
|
43
|
+
* }),
|
|
44
|
+
* version: new OasServerVariable({
|
|
45
|
+
* default: 'v1',
|
|
46
|
+
* description: 'API version'
|
|
47
|
+
* })
|
|
48
|
+
* }
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
11
52
|
export declare class OasServer {
|
|
53
|
+
/** Type identifier for this OAS server */
|
|
12
54
|
oasType: 'server';
|
|
55
|
+
/** Human-readable description of the server */
|
|
13
56
|
description: string | undefined;
|
|
57
|
+
/** Server URL with optional variable templating */
|
|
14
58
|
url: string;
|
|
59
|
+
/** Variable definitions for URL templating */
|
|
15
60
|
variables: Record<string, OasServerVariable> | undefined;
|
|
61
|
+
/** Custom extension fields (x-* properties) */
|
|
16
62
|
extensionFields: Record<string, unknown> | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a new OasServer instance.
|
|
65
|
+
*
|
|
66
|
+
* @param fields - Server configuration including URL, description, and variables
|
|
67
|
+
*/
|
|
17
68
|
constructor(fields: ServerFields);
|
|
69
|
+
/**
|
|
70
|
+
* Determines if this server is a reference object.
|
|
71
|
+
*
|
|
72
|
+
* @returns Always false since servers are not reference objects in OpenAPI
|
|
73
|
+
*/
|
|
18
74
|
isRef(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Resolves this server object.
|
|
77
|
+
*
|
|
78
|
+
* @returns The server instance itself since it's already a concrete object
|
|
79
|
+
*/
|
|
19
80
|
resolve(): OasServer;
|
|
81
|
+
/**
|
|
82
|
+
* Resolves this server object one level.
|
|
83
|
+
*
|
|
84
|
+
* @returns The server instance itself since it's already a concrete object
|
|
85
|
+
*/
|
|
20
86
|
resolveOnce(): OasServer;
|
|
87
|
+
/**
|
|
88
|
+
* Converts this OAS server to an OpenAPI v3 JSON schema representation.
|
|
89
|
+
*
|
|
90
|
+
* @param _options - Conversion options (currently unused for server objects)
|
|
91
|
+
* @returns OpenAPI v3 server object with URL, description, and variables
|
|
92
|
+
*/
|
|
21
93
|
toJsonSchema(_options: ToJsonSchemaOptions): OpenAPIV3.ServerObject;
|
|
22
94
|
}
|
|
23
95
|
//# sourceMappingURL=Server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../../src/oas/server/Server.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAE5E,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAAS,CAAA;IACzD,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED,qBAAa,SAAS;IACpB,OAAO,EAAE,QAAQ,CAAW;IAC5B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAAS,CAAA;IACxD,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../../src/oas/server/Server.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAE5E;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAAS,CAAA;IACzD,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,SAAS;IACpB,0CAA0C;IAC1C,OAAO,EAAE,QAAQ,CAAW;IAC5B,+CAA+C;IAC/C,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAA;IACX,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAAS,CAAA;IACxD,+CAA+C;IAC/C,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;IACpD;;;;OAIG;gBACS,MAAM,EAAE,YAAY;IAOhC;;;;OAIG;IACH,KAAK,IAAI,OAAO;IAIhB;;;;OAIG;IACH,OAAO,IAAI,SAAS;IAIpB;;;;OAIG;IACH,WAAW,IAAI,SAAS;IAIxB;;;;;OAKG;IACH,YAAY,CAAC,QAAQ,EAAE,mBAAmB,GAAG,SAAS,CAAC,YAAY;CAOpE"}
|
|
@@ -2,32 +2,77 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OasServer = void 0;
|
|
4
4
|
require("../../_dnt.polyfills.js");
|
|
5
|
+
/**
|
|
6
|
+
* Represents a Server Object in the OpenAPI Specification.
|
|
7
|
+
*
|
|
8
|
+
* The `OasServer` class encapsulates server connectivity information, including
|
|
9
|
+
* the server URL, optional description, and variable definitions for URL templating.
|
|
10
|
+
* Servers are used to specify different environments (development, staging, production)
|
|
11
|
+
* or different API versions that clients can connect to.
|
|
12
|
+
*
|
|
13
|
+
* @example Basic server
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const server = new OasServer({
|
|
16
|
+
* url: 'https://api.example.com/v1',
|
|
17
|
+
* description: 'Production API server'
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example Server with variables
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const server = new OasServer({
|
|
24
|
+
* url: 'https://{environment}.example.com/{version}',
|
|
25
|
+
* description: 'Configurable API server',
|
|
26
|
+
* variables: {
|
|
27
|
+
* environment: new OasServerVariable({
|
|
28
|
+
* enum: ['api', 'staging', 'dev'],
|
|
29
|
+
* default: 'api',
|
|
30
|
+
* description: 'API environment'
|
|
31
|
+
* }),
|
|
32
|
+
* version: new OasServerVariable({
|
|
33
|
+
* default: 'v1',
|
|
34
|
+
* description: 'API version'
|
|
35
|
+
* })
|
|
36
|
+
* }
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
5
40
|
class OasServer {
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new OasServer instance.
|
|
43
|
+
*
|
|
44
|
+
* @param fields - Server configuration including URL, description, and variables
|
|
45
|
+
*/
|
|
6
46
|
constructor(fields) {
|
|
47
|
+
/** Type identifier for this OAS server */
|
|
7
48
|
Object.defineProperty(this, "oasType", {
|
|
8
49
|
enumerable: true,
|
|
9
50
|
configurable: true,
|
|
10
51
|
writable: true,
|
|
11
52
|
value: 'server'
|
|
12
53
|
});
|
|
54
|
+
/** Human-readable description of the server */
|
|
13
55
|
Object.defineProperty(this, "description", {
|
|
14
56
|
enumerable: true,
|
|
15
57
|
configurable: true,
|
|
16
58
|
writable: true,
|
|
17
59
|
value: void 0
|
|
18
60
|
});
|
|
61
|
+
/** Server URL with optional variable templating */
|
|
19
62
|
Object.defineProperty(this, "url", {
|
|
20
63
|
enumerable: true,
|
|
21
64
|
configurable: true,
|
|
22
65
|
writable: true,
|
|
23
66
|
value: void 0
|
|
24
67
|
});
|
|
68
|
+
/** Variable definitions for URL templating */
|
|
25
69
|
Object.defineProperty(this, "variables", {
|
|
26
70
|
enumerable: true,
|
|
27
71
|
configurable: true,
|
|
28
72
|
writable: true,
|
|
29
73
|
value: void 0
|
|
30
74
|
});
|
|
75
|
+
/** Custom extension fields (x-* properties) */
|
|
31
76
|
Object.defineProperty(this, "extensionFields", {
|
|
32
77
|
enumerable: true,
|
|
33
78
|
configurable: true,
|
|
@@ -39,15 +84,36 @@ class OasServer {
|
|
|
39
84
|
this.variables = fields.variables;
|
|
40
85
|
this.extensionFields = fields.extensionFields;
|
|
41
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Determines if this server is a reference object.
|
|
89
|
+
*
|
|
90
|
+
* @returns Always false since servers are not reference objects in OpenAPI
|
|
91
|
+
*/
|
|
42
92
|
isRef() {
|
|
43
93
|
return false;
|
|
44
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Resolves this server object.
|
|
97
|
+
*
|
|
98
|
+
* @returns The server instance itself since it's already a concrete object
|
|
99
|
+
*/
|
|
45
100
|
resolve() {
|
|
46
101
|
return this;
|
|
47
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Resolves this server object one level.
|
|
105
|
+
*
|
|
106
|
+
* @returns The server instance itself since it's already a concrete object
|
|
107
|
+
*/
|
|
48
108
|
resolveOnce() {
|
|
49
109
|
return this;
|
|
50
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Converts this OAS server to an OpenAPI v3 JSON schema representation.
|
|
113
|
+
*
|
|
114
|
+
* @param _options - Conversion options (currently unused for server objects)
|
|
115
|
+
* @returns OpenAPI v3 server object with URL, description, and variables
|
|
116
|
+
*/
|
|
51
117
|
toJsonSchema(_options) {
|
|
52
118
|
return {
|
|
53
119
|
description: this.description,
|