@strapi/openapi 5.50.1 → 5.51.0
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/dist/assemblers/document/factory.d.ts +2 -0
- package/dist/assemblers/document/factory.d.ts.map +1 -1
- package/dist/assemblers/document/factory.js +10 -0
- package/dist/assemblers/document/factory.js.map +1 -1
- package/dist/assemblers/document/factory.mjs +10 -0
- package/dist/assemblers/document/factory.mjs.map +1 -1
- package/dist/assemblers/document/path/path-item/operation/parameters.d.ts +6 -0
- package/dist/assemblers/document/path/path-item/operation/parameters.d.ts.map +1 -1
- package/dist/assemblers/document/path/path-item/operation/parameters.js +104 -12
- package/dist/assemblers/document/path/path-item/operation/parameters.js.map +1 -1
- package/dist/assemblers/document/path/path-item/operation/parameters.mjs +104 -12
- package/dist/assemblers/document/path/path-item/operation/parameters.mjs.map +1 -1
- package/dist/assemblers/document/query-param-styles.d.ts +10 -0
- package/dist/assemblers/document/query-param-styles.d.ts.map +1 -0
- package/dist/assemblers/document/query-param-styles.js +23 -0
- package/dist/assemblers/document/query-param-styles.js.map +1 -0
- package/dist/assemblers/document/query-param-styles.mjs +19 -0
- package/dist/assemblers/document/query-param-styles.mjs.map +1 -0
- package/dist/assemblers/document/security.d.ts +8 -0
- package/dist/assemblers/document/security.d.ts.map +1 -0
- package/dist/assemblers/document/security.js +45 -0
- package/dist/assemblers/document/security.js.map +1 -0
- package/dist/assemblers/document/security.mjs +43 -0
- package/dist/assemblers/document/security.mjs.map +1 -0
- package/dist/assemblers/document/server.d.ts +13 -0
- package/dist/assemblers/document/server.d.ts.map +1 -0
- package/dist/assemblers/document/server.js +25 -0
- package/dist/assemblers/document/server.js.map +1 -0
- package/dist/assemblers/document/server.mjs +23 -0
- package/dist/assemblers/document/server.mjs.map +1 -0
- package/dist/post-processor/component-writer.d.ts.map +1 -1
- package/dist/post-processor/component-writer.js +7 -0
- package/dist/post-processor/component-writer.js.map +1 -1
- package/dist/post-processor/component-writer.mjs +8 -1
- package/dist/post-processor/component-writer.mjs.map +1 -1
- package/dist/utils/zod.d.ts +6 -0
- package/dist/utils/zod.d.ts.map +1 -1
- package/dist/utils/zod.js +12 -1
- package/dist/utils/zod.js.map +1 -1
- package/dist/utils/zod.mjs +12 -2
- package/dist/utils/zod.mjs.map +1 -1
- package/package.json +9 -5
|
@@ -3,6 +3,8 @@ export declare class DocumentAssemblerFactory {
|
|
|
3
3
|
createAll(): Assembler.Document[];
|
|
4
4
|
private _createInfoAssembler;
|
|
5
5
|
private _createMetadataAssembler;
|
|
6
|
+
private _createSecurityAssembler;
|
|
7
|
+
private _createServerAssembler;
|
|
6
8
|
private _createPathsAssembler;
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/assemblers/document/factory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/assemblers/document/factory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAQpC,qBAAa,wBAAwB;IACnC,SAAS,IAAI,SAAS,CAAC,QAAQ,EAAE;IAUjC,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,wBAAwB;IAIhC,OAAO,CAAC,wBAAwB;IAIhC,OAAO,CAAC,sBAAsB;IAI9B,OAAO,CAAC,qBAAqB;CAQ9B"}
|
|
@@ -13,12 +13,16 @@ require('./path/path-item/operation/operation.js');
|
|
|
13
13
|
require('./path/path-item/operation/operation-id.js');
|
|
14
14
|
require('./path/path-item/operation/parameters.js');
|
|
15
15
|
require('./path/path-item/operation/tags.js');
|
|
16
|
+
var security = require('./security.js');
|
|
17
|
+
var server = require('./server.js');
|
|
16
18
|
|
|
17
19
|
class DocumentAssemblerFactory {
|
|
18
20
|
createAll() {
|
|
19
21
|
return [
|
|
20
22
|
this._createMetadataAssembler(),
|
|
21
23
|
this._createInfoAssembler(),
|
|
24
|
+
this._createServerAssembler(),
|
|
25
|
+
this._createSecurityAssembler(),
|
|
22
26
|
this._createPathsAssembler()
|
|
23
27
|
];
|
|
24
28
|
}
|
|
@@ -28,6 +32,12 @@ class DocumentAssemblerFactory {
|
|
|
28
32
|
_createMetadataAssembler() {
|
|
29
33
|
return new metadata.DocumentMetadataAssembler();
|
|
30
34
|
}
|
|
35
|
+
_createSecurityAssembler() {
|
|
36
|
+
return new security.DocumentSecurityAssembler();
|
|
37
|
+
}
|
|
38
|
+
_createServerAssembler() {
|
|
39
|
+
return new server.DocumentServerAssembler();
|
|
40
|
+
}
|
|
31
41
|
_createPathsAssembler(assemblerFactory = new factory.PathAssemblerFactory(), contextFactory = new path.PathContextFactory()) {
|
|
32
42
|
const assemblers = assemblerFactory.createAll();
|
|
33
43
|
return new path$1.DocumentPathsAssembler(assemblers, contextFactory);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sources":["../../../src/assemblers/document/factory.ts"],"sourcesContent":["import { PathContextFactory } from '../../context';\n\nimport type { Assembler } from '..';\n\nimport { DocumentInfoAssembler } from './info';\nimport { DocumentMetadataAssembler } from './metadata';\nimport { DocumentPathsAssembler, PathAssemblerFactory } from './path';\n\nexport class DocumentAssemblerFactory {\n createAll(): Assembler.Document[] {\n return [\n this._createMetadataAssembler(),\n this._createInfoAssembler(),\n this._createPathsAssembler(),\n ];\n }\n\n private _createInfoAssembler() {\n return new DocumentInfoAssembler();\n }\n\n private _createMetadataAssembler() {\n return new DocumentMetadataAssembler();\n }\n\n private _createPathsAssembler(\n assemblerFactory: PathAssemblerFactory = new PathAssemblerFactory(),\n contextFactory: PathContextFactory = new PathContextFactory()\n ) {\n const assemblers = assemblerFactory.createAll();\n\n return new DocumentPathsAssembler(assemblers, contextFactory);\n }\n}\n"],"names":["DocumentAssemblerFactory","createAll","_createMetadataAssembler","_createInfoAssembler","_createPathsAssembler","DocumentInfoAssembler","DocumentMetadataAssembler","assemblerFactory","PathAssemblerFactory","contextFactory","PathContextFactory","assemblers","DocumentPathsAssembler"],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.js","sources":["../../../src/assemblers/document/factory.ts"],"sourcesContent":["import { PathContextFactory } from '../../context';\n\nimport type { Assembler } from '..';\n\nimport { DocumentInfoAssembler } from './info';\nimport { DocumentMetadataAssembler } from './metadata';\nimport { DocumentPathsAssembler, PathAssemblerFactory } from './path';\nimport { DocumentSecurityAssembler } from './security';\nimport { DocumentServerAssembler } from './server';\n\nexport class DocumentAssemblerFactory {\n createAll(): Assembler.Document[] {\n return [\n this._createMetadataAssembler(),\n this._createInfoAssembler(),\n this._createServerAssembler(),\n this._createSecurityAssembler(),\n this._createPathsAssembler(),\n ];\n }\n\n private _createInfoAssembler() {\n return new DocumentInfoAssembler();\n }\n\n private _createMetadataAssembler() {\n return new DocumentMetadataAssembler();\n }\n\n private _createSecurityAssembler() {\n return new DocumentSecurityAssembler();\n }\n\n private _createServerAssembler() {\n return new DocumentServerAssembler();\n }\n\n private _createPathsAssembler(\n assemblerFactory: PathAssemblerFactory = new PathAssemblerFactory(),\n contextFactory: PathContextFactory = new PathContextFactory()\n ) {\n const assemblers = assemblerFactory.createAll();\n\n return new DocumentPathsAssembler(assemblers, contextFactory);\n }\n}\n"],"names":["DocumentAssemblerFactory","createAll","_createMetadataAssembler","_createInfoAssembler","_createServerAssembler","_createSecurityAssembler","_createPathsAssembler","DocumentInfoAssembler","DocumentMetadataAssembler","DocumentSecurityAssembler","DocumentServerAssembler","assemblerFactory","PathAssemblerFactory","contextFactory","PathContextFactory","assemblers","DocumentPathsAssembler"],"mappings":";;;;;;;;;;;;;;;;;;AAUO,MAAMA,wBAAAA,CAAAA;IACXC,SAAAA,GAAkC;QAChC,OAAO;AACL,YAAA,IAAI,CAACC,wBAAwB,EAAA;AAC7B,YAAA,IAAI,CAACC,oBAAoB,EAAA;AACzB,YAAA,IAAI,CAACC,sBAAsB,EAAA;AAC3B,YAAA,IAAI,CAACC,wBAAwB,EAAA;AAC7B,YAAA,IAAI,CAACC,qBAAqB;AAC3B,SAAA;AACH,IAAA;IAEQH,oBAAAA,GAAuB;AAC7B,QAAA,OAAO,IAAII,0BAAAA,EAAAA;AACb,IAAA;IAEQL,wBAAAA,GAA2B;AACjC,QAAA,OAAO,IAAIM,kCAAAA,EAAAA;AACb,IAAA;IAEQH,wBAAAA,GAA2B;AACjC,QAAA,OAAO,IAAII,kCAAAA,EAAAA;AACb,IAAA;IAEQL,sBAAAA,GAAyB;AAC/B,QAAA,OAAO,IAAIM,8BAAAA,EAAAA;AACb,IAAA;AAEQJ,IAAAA,qBAAAA,CACNK,mBAAyC,IAAIC,4BAAAA,EAAsB,EACnEC,cAAAA,GAAqC,IAAIC,yBAAoB,EAC7D;QACA,MAAMC,UAAAA,GAAaJ,iBAAiBV,SAAS,EAAA;QAE7C,OAAO,IAAIe,8BAAuBD,UAAAA,EAAYF,cAAAA,CAAAA;AAChD,IAAA;AACF;;;;"}
|
|
@@ -11,12 +11,16 @@ import './path/path-item/operation/operation.mjs';
|
|
|
11
11
|
import './path/path-item/operation/operation-id.mjs';
|
|
12
12
|
import './path/path-item/operation/parameters.mjs';
|
|
13
13
|
import './path/path-item/operation/tags.mjs';
|
|
14
|
+
import { DocumentSecurityAssembler } from './security.mjs';
|
|
15
|
+
import { DocumentServerAssembler } from './server.mjs';
|
|
14
16
|
|
|
15
17
|
class DocumentAssemblerFactory {
|
|
16
18
|
createAll() {
|
|
17
19
|
return [
|
|
18
20
|
this._createMetadataAssembler(),
|
|
19
21
|
this._createInfoAssembler(),
|
|
22
|
+
this._createServerAssembler(),
|
|
23
|
+
this._createSecurityAssembler(),
|
|
20
24
|
this._createPathsAssembler()
|
|
21
25
|
];
|
|
22
26
|
}
|
|
@@ -26,6 +30,12 @@ class DocumentAssemblerFactory {
|
|
|
26
30
|
_createMetadataAssembler() {
|
|
27
31
|
return new DocumentMetadataAssembler();
|
|
28
32
|
}
|
|
33
|
+
_createSecurityAssembler() {
|
|
34
|
+
return new DocumentSecurityAssembler();
|
|
35
|
+
}
|
|
36
|
+
_createServerAssembler() {
|
|
37
|
+
return new DocumentServerAssembler();
|
|
38
|
+
}
|
|
29
39
|
_createPathsAssembler(assemblerFactory = new PathAssemblerFactory(), contextFactory = new PathContextFactory()) {
|
|
30
40
|
const assemblers = assemblerFactory.createAll();
|
|
31
41
|
return new DocumentPathsAssembler(assemblers, contextFactory);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.mjs","sources":["../../../src/assemblers/document/factory.ts"],"sourcesContent":["import { PathContextFactory } from '../../context';\n\nimport type { Assembler } from '..';\n\nimport { DocumentInfoAssembler } from './info';\nimport { DocumentMetadataAssembler } from './metadata';\nimport { DocumentPathsAssembler, PathAssemblerFactory } from './path';\n\nexport class DocumentAssemblerFactory {\n createAll(): Assembler.Document[] {\n return [\n this._createMetadataAssembler(),\n this._createInfoAssembler(),\n this._createPathsAssembler(),\n ];\n }\n\n private _createInfoAssembler() {\n return new DocumentInfoAssembler();\n }\n\n private _createMetadataAssembler() {\n return new DocumentMetadataAssembler();\n }\n\n private _createPathsAssembler(\n assemblerFactory: PathAssemblerFactory = new PathAssemblerFactory(),\n contextFactory: PathContextFactory = new PathContextFactory()\n ) {\n const assemblers = assemblerFactory.createAll();\n\n return new DocumentPathsAssembler(assemblers, contextFactory);\n }\n}\n"],"names":["DocumentAssemblerFactory","createAll","_createMetadataAssembler","_createInfoAssembler","_createPathsAssembler","DocumentInfoAssembler","DocumentMetadataAssembler","assemblerFactory","PathAssemblerFactory","contextFactory","PathContextFactory","assemblers","DocumentPathsAssembler"],"mappings":"
|
|
1
|
+
{"version":3,"file":"factory.mjs","sources":["../../../src/assemblers/document/factory.ts"],"sourcesContent":["import { PathContextFactory } from '../../context';\n\nimport type { Assembler } from '..';\n\nimport { DocumentInfoAssembler } from './info';\nimport { DocumentMetadataAssembler } from './metadata';\nimport { DocumentPathsAssembler, PathAssemblerFactory } from './path';\nimport { DocumentSecurityAssembler } from './security';\nimport { DocumentServerAssembler } from './server';\n\nexport class DocumentAssemblerFactory {\n createAll(): Assembler.Document[] {\n return [\n this._createMetadataAssembler(),\n this._createInfoAssembler(),\n this._createServerAssembler(),\n this._createSecurityAssembler(),\n this._createPathsAssembler(),\n ];\n }\n\n private _createInfoAssembler() {\n return new DocumentInfoAssembler();\n }\n\n private _createMetadataAssembler() {\n return new DocumentMetadataAssembler();\n }\n\n private _createSecurityAssembler() {\n return new DocumentSecurityAssembler();\n }\n\n private _createServerAssembler() {\n return new DocumentServerAssembler();\n }\n\n private _createPathsAssembler(\n assemblerFactory: PathAssemblerFactory = new PathAssemblerFactory(),\n contextFactory: PathContextFactory = new PathContextFactory()\n ) {\n const assemblers = assemblerFactory.createAll();\n\n return new DocumentPathsAssembler(assemblers, contextFactory);\n }\n}\n"],"names":["DocumentAssemblerFactory","createAll","_createMetadataAssembler","_createInfoAssembler","_createServerAssembler","_createSecurityAssembler","_createPathsAssembler","DocumentInfoAssembler","DocumentMetadataAssembler","DocumentSecurityAssembler","DocumentServerAssembler","assemblerFactory","PathAssemblerFactory","contextFactory","PathContextFactory","assemblers","DocumentPathsAssembler"],"mappings":";;;;;;;;;;;;;;;;AAUO,MAAMA,wBAAAA,CAAAA;IACXC,SAAAA,GAAkC;QAChC,OAAO;AACL,YAAA,IAAI,CAACC,wBAAwB,EAAA;AAC7B,YAAA,IAAI,CAACC,oBAAoB,EAAA;AACzB,YAAA,IAAI,CAACC,sBAAsB,EAAA;AAC3B,YAAA,IAAI,CAACC,wBAAwB,EAAA;AAC7B,YAAA,IAAI,CAACC,qBAAqB;AAC3B,SAAA;AACH,IAAA;IAEQH,oBAAAA,GAAuB;AAC7B,QAAA,OAAO,IAAII,qBAAAA,EAAAA;AACb,IAAA;IAEQL,wBAAAA,GAA2B;AACjC,QAAA,OAAO,IAAIM,yBAAAA,EAAAA;AACb,IAAA;IAEQH,wBAAAA,GAA2B;AACjC,QAAA,OAAO,IAAII,yBAAAA,EAAAA;AACb,IAAA;IAEQL,sBAAAA,GAAyB;AAC/B,QAAA,OAAO,IAAIM,uBAAAA,EAAAA;AACb,IAAA;AAEQJ,IAAAA,qBAAAA,CACNK,mBAAyC,IAAIC,oBAAAA,EAAsB,EACnEC,cAAAA,GAAqC,IAAIC,oBAAoB,EAC7D;QACA,MAAMC,UAAAA,GAAaJ,iBAAiBV,SAAS,EAAA;QAE7C,OAAO,IAAIe,uBAAuBD,UAAAA,EAAYF,cAAAA,CAAAA;AAChD,IAAA;AACF;;;;"}
|
|
@@ -5,5 +5,11 @@ export declare class OperationParametersAssembler implements Assembler.Operation
|
|
|
5
5
|
assemble(context: OperationContext, route: Core.Route): void;
|
|
6
6
|
private _getPathParameters;
|
|
7
7
|
private _getQueryParameters;
|
|
8
|
+
/**
|
|
9
|
+
* Resolve composite OpenAPI schemas (allOf/anyOf/oneOf) into a flat object shape
|
|
10
|
+
* so nested Strapi query params can be emitted as bracket notation (e.g. pagination[page]).
|
|
11
|
+
*/
|
|
12
|
+
private _resolveSchema;
|
|
13
|
+
private _extractCommonProperties;
|
|
8
14
|
}
|
|
9
15
|
//# sourceMappingURL=parameters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../../../../src/assemblers/document/path/path-item/operation/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../../../../src/assemblers/document/path/path-item/operation/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAY7D,qBAAa,4BAA6B,YAAW,SAAS,CAAC,SAAS;IACtE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI;IAe5D,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,mBAAmB;IAmD3B;;;OAGG;IACH,OAAO,CAAC,cAAc;IA2CtB,OAAO,CAAC,wBAAwB;CAqCjC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var debug$1 = require('../../../../../utils/debug.js');
|
|
4
4
|
var zod = require('../../../../../utils/zod.js');
|
|
5
|
+
var queryParamStyles = require('../../../query-param-styles.js');
|
|
5
6
|
|
|
6
7
|
const debug = debug$1.createDebugger('assembler:parameters');
|
|
7
8
|
class OperationParametersAssembler {
|
|
@@ -46,21 +47,112 @@ class OperationParametersAssembler {
|
|
|
46
47
|
for (const [name, zodSchema] of Object.entries(query)){
|
|
47
48
|
const required = !zodSchema.isOptional();
|
|
48
49
|
const schema = zod.zodToOpenAPI(zodSchema);
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
const resolvedSchema = this._resolveSchema(schema);
|
|
51
|
+
if (queryParamStyles.hasExpandableObjectProperties(resolvedSchema)) {
|
|
52
|
+
for (const [propName, propSchema] of Object.entries(resolvedSchema.properties)){
|
|
53
|
+
const isRequired = resolvedSchema.required?.includes(propName) ?? false;
|
|
54
|
+
const param = {
|
|
55
|
+
name: `${name}[${propName}]`,
|
|
56
|
+
in: 'query',
|
|
57
|
+
required: isRequired,
|
|
58
|
+
schema: propSchema
|
|
59
|
+
};
|
|
60
|
+
Object.assign(param, {
|
|
61
|
+
'x-strapi-serialize': 'querystring'
|
|
62
|
+
});
|
|
63
|
+
queryParams.push(param);
|
|
64
|
+
}
|
|
65
|
+
} else if (queryParamStyles.shouldUseDeepObjectStyle(name, resolvedSchema)) {
|
|
66
|
+
const param = {
|
|
67
|
+
name,
|
|
68
|
+
in: 'query',
|
|
69
|
+
required,
|
|
70
|
+
schema: resolvedSchema,
|
|
71
|
+
style: 'deepObject',
|
|
72
|
+
explode: true
|
|
73
|
+
};
|
|
74
|
+
Object.assign(param, {
|
|
75
|
+
'x-strapi-serialize': 'querystring'
|
|
76
|
+
});
|
|
77
|
+
queryParams.push(param);
|
|
78
|
+
} else {
|
|
79
|
+
const param = {
|
|
80
|
+
name,
|
|
81
|
+
in: 'query',
|
|
82
|
+
required,
|
|
83
|
+
schema
|
|
84
|
+
};
|
|
85
|
+
Object.assign(param, {
|
|
86
|
+
'x-strapi-serialize': 'querystring'
|
|
87
|
+
});
|
|
88
|
+
queryParams.push(param);
|
|
89
|
+
}
|
|
61
90
|
}
|
|
62
91
|
return queryParams;
|
|
63
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Resolve composite OpenAPI schemas (allOf/anyOf/oneOf) into a flat object shape
|
|
95
|
+
* so nested Strapi query params can be emitted as bracket notation (e.g. pagination[page]).
|
|
96
|
+
*/ _resolveSchema(schema) {
|
|
97
|
+
if (schema.type === 'object' && schema.properties) {
|
|
98
|
+
return schema;
|
|
99
|
+
}
|
|
100
|
+
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
101
|
+
const mergedSchema = {
|
|
102
|
+
type: 'object',
|
|
103
|
+
properties: {},
|
|
104
|
+
required: []
|
|
105
|
+
};
|
|
106
|
+
for (const subSchema of schema.allOf){
|
|
107
|
+
if (!('$ref' in subSchema)) {
|
|
108
|
+
const hasAnyOfOneOf = Boolean(subSchema.anyOf || subSchema.oneOf);
|
|
109
|
+
const resolved = this._resolveSchema(subSchema);
|
|
110
|
+
if (resolved.type === 'object' && resolved.properties) {
|
|
111
|
+
Object.assign(mergedSchema.properties, resolved.properties);
|
|
112
|
+
if (resolved.required && !hasAnyOfOneOf) {
|
|
113
|
+
mergedSchema.required = [
|
|
114
|
+
...mergedSchema.required ?? [],
|
|
115
|
+
...resolved.required
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return queryParamStyles.hasExpandableObjectProperties(mergedSchema) ? mergedSchema : schema;
|
|
122
|
+
}
|
|
123
|
+
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
124
|
+
return this._extractCommonProperties(schema.anyOf, false);
|
|
125
|
+
}
|
|
126
|
+
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
127
|
+
return this._extractCommonProperties(schema.oneOf, false);
|
|
128
|
+
}
|
|
129
|
+
return schema;
|
|
130
|
+
}
|
|
131
|
+
_extractCommonProperties(schemas, preserveRequired = true) {
|
|
132
|
+
const objectSchemas = schemas.filter((s)=>!('$ref' in s)).map((s)=>this._resolveSchema(s)).filter((s)=>s.type === 'object' && s.properties);
|
|
133
|
+
if (objectSchemas.length === 0) {
|
|
134
|
+
return schemas[0];
|
|
135
|
+
}
|
|
136
|
+
const allProperties = {};
|
|
137
|
+
let allRequired = [];
|
|
138
|
+
for (const objSchema of objectSchemas){
|
|
139
|
+
Object.assign(allProperties, objSchema.properties);
|
|
140
|
+
if (preserveRequired && objSchema.required) {
|
|
141
|
+
allRequired.push(...objSchema.required);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (!preserveRequired) {
|
|
145
|
+
allRequired = [];
|
|
146
|
+
}
|
|
147
|
+
if (Object.keys(allProperties).length === 0) {
|
|
148
|
+
return schemas[0];
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
type: 'object',
|
|
152
|
+
properties: allProperties,
|
|
153
|
+
required: allRequired
|
|
154
|
+
};
|
|
155
|
+
}
|
|
64
156
|
}
|
|
65
157
|
|
|
66
158
|
exports.OperationParametersAssembler = OperationParametersAssembler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.js","sources":["../../../../../../src/assemblers/document/path/path-item/operation/parameters.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport type { OpenAPIV3_1 } from 'openapi-types';\nimport type { Assembler } from '../../../..';\n\nimport type { OperationContext } from '../../../../../types';\nimport { createDebugger, zodToOpenAPI } from '../../../../../utils';\n\nconst debug = createDebugger('assembler:parameters');\n\ntype PathParameterObject = OpenAPIV3_1.ParameterObject & { in: 'path' };\ntype QueryParameterObject = OpenAPIV3_1.ParameterObject & { in: 'query' };\n\nexport class OperationParametersAssembler implements Assembler.Operation {\n assemble(context: OperationContext, route: Core.Route): void {\n debug('assembling parameters for %o %o...', route.method, route.path);\n\n const pathParameters = this._getPathParameters(route);\n debug('found %o path parameters', pathParameters.length);\n\n const queryParameters = this._getQueryParameters(route);\n debug('found %o query parameters', queryParameters.length);\n\n const parameters = [...pathParameters, ...queryParameters];\n debug('assembled %o parameters for %o %o', parameters.length, route.method, route.path);\n\n context.output.data.parameters = parameters;\n }\n\n private _getPathParameters(route: Core.Route): PathParameterObject[] {\n const { params } = route.request ?? {};\n\n // TODO: Allow auto inference (from path) if enabled through configuration\n if (!params) {\n return [];\n }\n\n const pathParams: PathParameterObject[] = [];\n\n for (const [name, zodSchema] of Object.entries(params)) {\n const required = !zodSchema.isOptional();\n const schema = zodToOpenAPI(zodSchema) as any;\n\n pathParams.push({ name, in: 'path', required, schema });\n }\n\n return pathParams;\n }\n\n private _getQueryParameters(route: Core.Route): QueryParameterObject[] {\n const { query } = route.request ?? {};\n\n if (!query) {\n return [];\n }\n\n const queryParams: QueryParameterObject[] = [];\n\n for (const [name, zodSchema] of Object.entries(query)) {\n const required = !zodSchema.isOptional();\n const schema = zodToOpenAPI(zodSchema) as any;\n const param: QueryParameterObject = { name, in: 'query', required, schema };\n\n // In Strapi, query params are always interpreted as query strings, which isn't supported by the specification\n // TODO: Make that configurable somehow\n Object.assign(param, { 'x-strapi-serialize': 'querystring' });\n\n queryParams.push(param);\n }\n\n return queryParams;\n }\n}\n"],"names":["debug","createDebugger","OperationParametersAssembler","assemble","context","route","method","path","pathParameters","_getPathParameters","length","queryParameters","_getQueryParameters","parameters","output","data","params","request","pathParams","name","zodSchema","Object","entries","required","isOptional","schema","zodToOpenAPI","push","in","query","queryParams","param","assign"],"mappings":";;;;;AAOA,MAAMA,QAAQC,sBAAAA,CAAe,sBAAA,CAAA;AAKtB,MAAMC,4BAAAA,CAAAA;IACXC,QAAAA,CAASC,OAAyB,EAAEC,KAAiB,EAAQ;AAC3DL,QAAAA,KAAAA,CAAM,oCAAA,EAAsCK,KAAAA,CAAMC,MAAM,EAAED,MAAME,IAAI,CAAA;AAEpE,QAAA,MAAMC,cAAAA,GAAiB,IAAI,CAACC,kBAAkB,CAACJ,KAAAA,CAAAA;QAC/CL,KAAAA,CAAM,0BAAA,EAA4BQ,eAAeE,MAAM,CAAA;AAEvD,QAAA,MAAMC,eAAAA,GAAkB,IAAI,CAACC,mBAAmB,CAACP,KAAAA,CAAAA;QACjDL,KAAAA,CAAM,2BAAA,EAA6BW,gBAAgBD,MAAM,CAAA;AAEzD,QAAA,MAAMG,UAAAA,GAAa;AAAIL,YAAAA,GAAAA,cAAAA;AAAmBG,YAAAA,GAAAA;AAAgB,SAAA;QAC1DX,KAAAA,CAAM,mCAAA,EAAqCa,WAAWH,MAAM,EAAEL,MAAMC,MAAM,EAAED,MAAME,IAAI,CAAA;AAEtFH,QAAAA,OAAAA,CAAQU,MAAM,CAACC,IAAI,CAACF,UAAU,GAAGA,UAAAA;AACnC,IAAA;AAEQJ,IAAAA,kBAAAA,CAAmBJ,KAAiB,EAAyB;AACnE,QAAA,MAAM,EAAEW,MAAM,EAAE,GAAGX,KAAAA,CAAMY,OAAO,IAAI,EAAC;;AA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AACI,KAAAA,CAAAA;AACnB,QAAA;QAEA,OAAOD,WAAAA;AACT,IAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"parameters.js","sources":["../../../../../../src/assemblers/document/path/path-item/operation/parameters.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport type { OpenAPIV3_1 } from 'openapi-types';\nimport type { Assembler } from '../../../..';\n\nimport type { OperationContext } from '../../../../../types';\nimport { createDebugger, zodToOpenAPI } from '../../../../../utils';\nimport {\n hasExpandableObjectProperties,\n shouldUseDeepObjectStyle,\n} from '../../../query-param-styles';\n\nconst debug = createDebugger('assembler:parameters');\n\ntype PathParameterObject = OpenAPIV3_1.ParameterObject & { in: 'path' };\ntype QueryParameterObject = OpenAPIV3_1.ParameterObject & { in: 'query' };\n\nexport class OperationParametersAssembler implements Assembler.Operation {\n assemble(context: OperationContext, route: Core.Route): void {\n debug('assembling parameters for %o %o...', route.method, route.path);\n\n const pathParameters = this._getPathParameters(route);\n debug('found %o path parameters', pathParameters.length);\n\n const queryParameters = this._getQueryParameters(route);\n debug('found %o query parameters', queryParameters.length);\n\n const parameters = [...pathParameters, ...queryParameters];\n debug('assembled %o parameters for %o %o', parameters.length, route.method, route.path);\n\n context.output.data.parameters = parameters;\n }\n\n private _getPathParameters(route: Core.Route): PathParameterObject[] {\n const { params } = route.request ?? {};\n\n // TODO: Allow auto inference (from path) if enabled through configuration\n if (!params) {\n return [];\n }\n\n const pathParams: PathParameterObject[] = [];\n\n for (const [name, zodSchema] of Object.entries(params)) {\n const required = !zodSchema.isOptional();\n const schema = zodToOpenAPI(zodSchema) as any;\n\n pathParams.push({ name, in: 'path', required, schema });\n }\n\n return pathParams;\n }\n\n private _getQueryParameters(route: Core.Route): QueryParameterObject[] {\n const { query } = route.request ?? {};\n\n if (!query) {\n return [];\n }\n\n const queryParams: QueryParameterObject[] = [];\n\n for (const [name, zodSchema] of Object.entries(query)) {\n const required = !zodSchema.isOptional();\n const schema = zodToOpenAPI(zodSchema) as any;\n\n const resolvedSchema = this._resolveSchema(schema);\n\n if (hasExpandableObjectProperties(resolvedSchema)) {\n for (const [propName, propSchema] of Object.entries(resolvedSchema.properties!)) {\n const isRequired = resolvedSchema.required?.includes(propName) ?? false;\n\n const param: QueryParameterObject = {\n name: `${name}[${propName}]`,\n in: 'query',\n required: isRequired,\n schema: propSchema as any,\n };\n\n Object.assign(param, { 'x-strapi-serialize': 'querystring' });\n queryParams.push(param);\n }\n } else if (shouldUseDeepObjectStyle(name, resolvedSchema)) {\n const param: QueryParameterObject = {\n name,\n in: 'query',\n required,\n schema: resolvedSchema as any,\n style: 'deepObject',\n explode: true,\n };\n\n Object.assign(param, { 'x-strapi-serialize': 'querystring' });\n queryParams.push(param);\n } else {\n const param: QueryParameterObject = { name, in: 'query', required, schema };\n Object.assign(param, { 'x-strapi-serialize': 'querystring' });\n queryParams.push(param);\n }\n }\n\n return queryParams;\n }\n\n /**\n * Resolve composite OpenAPI schemas (allOf/anyOf/oneOf) into a flat object shape\n * so nested Strapi query params can be emitted as bracket notation (e.g. pagination[page]).\n */\n private _resolveSchema(schema: OpenAPIV3_1.SchemaObject): OpenAPIV3_1.SchemaObject {\n if (schema.type === 'object' && schema.properties) {\n return schema;\n }\n\n if (schema.allOf && Array.isArray(schema.allOf)) {\n const mergedSchema: OpenAPIV3_1.SchemaObject = {\n type: 'object',\n properties: {},\n required: [],\n };\n\n for (const subSchema of schema.allOf) {\n if (!('$ref' in subSchema)) {\n const hasAnyOfOneOf = Boolean(subSchema.anyOf || subSchema.oneOf);\n const resolved = this._resolveSchema(subSchema);\n\n if (resolved.type === 'object' && resolved.properties) {\n Object.assign(mergedSchema.properties!, resolved.properties);\n if (resolved.required && !hasAnyOfOneOf) {\n mergedSchema.required = [\n ...(mergedSchema.required ?? []),\n ...(resolved.required as string[]),\n ];\n }\n }\n }\n }\n\n return hasExpandableObjectProperties(mergedSchema) ? mergedSchema : schema;\n }\n\n if (schema.anyOf && Array.isArray(schema.anyOf)) {\n return this._extractCommonProperties(schema.anyOf, false);\n }\n\n if (schema.oneOf && Array.isArray(schema.oneOf)) {\n return this._extractCommonProperties(schema.oneOf, false);\n }\n\n return schema;\n }\n\n private _extractCommonProperties(\n schemas: OpenAPIV3_1.SchemaObject[],\n preserveRequired = true\n ): OpenAPIV3_1.SchemaObject {\n const objectSchemas = schemas\n .filter((s): s is OpenAPIV3_1.SchemaObject => !('$ref' in s))\n .map((s) => this._resolveSchema(s))\n .filter((s) => s.type === 'object' && s.properties);\n\n if (objectSchemas.length === 0) {\n return schemas[0] as OpenAPIV3_1.SchemaObject;\n }\n\n const allProperties: Record<string, OpenAPIV3_1.SchemaObject> = {};\n let allRequired: string[] = [];\n\n for (const objSchema of objectSchemas) {\n Object.assign(allProperties, objSchema.properties);\n if (preserveRequired && objSchema.required) {\n allRequired.push(...(objSchema.required as string[]));\n }\n }\n\n if (!preserveRequired) {\n allRequired = [];\n }\n\n if (Object.keys(allProperties).length === 0) {\n return schemas[0] as OpenAPIV3_1.SchemaObject;\n }\n\n return {\n type: 'object',\n properties: allProperties,\n required: allRequired,\n };\n }\n}\n"],"names":["debug","createDebugger","OperationParametersAssembler","assemble","context","route","method","path","pathParameters","_getPathParameters","length","queryParameters","_getQueryParameters","parameters","output","data","params","request","pathParams","name","zodSchema","Object","entries","required","isOptional","schema","zodToOpenAPI","push","in","query","queryParams","resolvedSchema","_resolveSchema","hasExpandableObjectProperties","propName","propSchema","properties","isRequired","includes","param","assign","shouldUseDeepObjectStyle","style","explode","type","allOf","Array","isArray","mergedSchema","subSchema","hasAnyOfOneOf","Boolean","anyOf","oneOf","resolved","_extractCommonProperties","schemas","preserveRequired","objectSchemas","filter","s","map","allProperties","allRequired","objSchema","keys"],"mappings":";;;;;;AAWA,MAAMA,QAAQC,sBAAAA,CAAe,sBAAA,CAAA;AAKtB,MAAMC,4BAAAA,CAAAA;IACXC,QAAAA,CAASC,OAAyB,EAAEC,KAAiB,EAAQ;AAC3DL,QAAAA,KAAAA,CAAM,oC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
import { hasExpandableObjectProperties, shouldUseDeepObjectStyle } from '../../../query-param-styles.mjs';
|
|
3
4
|
|
|
4
5
|
const debug = createDebugger('assembler:parameters');
|
|
5
6
|
class OperationParametersAssembler {
|
|
@@ -44,21 +45,112 @@ class OperationParametersAssembler {
|
|
|
44
45
|
for (const [name, zodSchema] of Object.entries(query)){
|
|
45
46
|
const required = !zodSchema.isOptional();
|
|
46
47
|
const schema = zodToOpenAPI(zodSchema);
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
const resolvedSchema = this._resolveSchema(schema);
|
|
49
|
+
if (hasExpandableObjectProperties(resolvedSchema)) {
|
|
50
|
+
for (const [propName, propSchema] of Object.entries(resolvedSchema.properties)){
|
|
51
|
+
const isRequired = resolvedSchema.required?.includes(propName) ?? false;
|
|
52
|
+
const param = {
|
|
53
|
+
name: `${name}[${propName}]`,
|
|
54
|
+
in: 'query',
|
|
55
|
+
required: isRequired,
|
|
56
|
+
schema: propSchema
|
|
57
|
+
};
|
|
58
|
+
Object.assign(param, {
|
|
59
|
+
'x-strapi-serialize': 'querystring'
|
|
60
|
+
});
|
|
61
|
+
queryParams.push(param);
|
|
62
|
+
}
|
|
63
|
+
} else if (shouldUseDeepObjectStyle(name, resolvedSchema)) {
|
|
64
|
+
const param = {
|
|
65
|
+
name,
|
|
66
|
+
in: 'query',
|
|
67
|
+
required,
|
|
68
|
+
schema: resolvedSchema,
|
|
69
|
+
style: 'deepObject',
|
|
70
|
+
explode: true
|
|
71
|
+
};
|
|
72
|
+
Object.assign(param, {
|
|
73
|
+
'x-strapi-serialize': 'querystring'
|
|
74
|
+
});
|
|
75
|
+
queryParams.push(param);
|
|
76
|
+
} else {
|
|
77
|
+
const param = {
|
|
78
|
+
name,
|
|
79
|
+
in: 'query',
|
|
80
|
+
required,
|
|
81
|
+
schema
|
|
82
|
+
};
|
|
83
|
+
Object.assign(param, {
|
|
84
|
+
'x-strapi-serialize': 'querystring'
|
|
85
|
+
});
|
|
86
|
+
queryParams.push(param);
|
|
87
|
+
}
|
|
59
88
|
}
|
|
60
89
|
return queryParams;
|
|
61
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Resolve composite OpenAPI schemas (allOf/anyOf/oneOf) into a flat object shape
|
|
93
|
+
* so nested Strapi query params can be emitted as bracket notation (e.g. pagination[page]).
|
|
94
|
+
*/ _resolveSchema(schema) {
|
|
95
|
+
if (schema.type === 'object' && schema.properties) {
|
|
96
|
+
return schema;
|
|
97
|
+
}
|
|
98
|
+
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
99
|
+
const mergedSchema = {
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {},
|
|
102
|
+
required: []
|
|
103
|
+
};
|
|
104
|
+
for (const subSchema of schema.allOf){
|
|
105
|
+
if (!('$ref' in subSchema)) {
|
|
106
|
+
const hasAnyOfOneOf = Boolean(subSchema.anyOf || subSchema.oneOf);
|
|
107
|
+
const resolved = this._resolveSchema(subSchema);
|
|
108
|
+
if (resolved.type === 'object' && resolved.properties) {
|
|
109
|
+
Object.assign(mergedSchema.properties, resolved.properties);
|
|
110
|
+
if (resolved.required && !hasAnyOfOneOf) {
|
|
111
|
+
mergedSchema.required = [
|
|
112
|
+
...mergedSchema.required ?? [],
|
|
113
|
+
...resolved.required
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return hasExpandableObjectProperties(mergedSchema) ? mergedSchema : schema;
|
|
120
|
+
}
|
|
121
|
+
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
122
|
+
return this._extractCommonProperties(schema.anyOf, false);
|
|
123
|
+
}
|
|
124
|
+
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
125
|
+
return this._extractCommonProperties(schema.oneOf, false);
|
|
126
|
+
}
|
|
127
|
+
return schema;
|
|
128
|
+
}
|
|
129
|
+
_extractCommonProperties(schemas, preserveRequired = true) {
|
|
130
|
+
const objectSchemas = schemas.filter((s)=>!('$ref' in s)).map((s)=>this._resolveSchema(s)).filter((s)=>s.type === 'object' && s.properties);
|
|
131
|
+
if (objectSchemas.length === 0) {
|
|
132
|
+
return schemas[0];
|
|
133
|
+
}
|
|
134
|
+
const allProperties = {};
|
|
135
|
+
let allRequired = [];
|
|
136
|
+
for (const objSchema of objectSchemas){
|
|
137
|
+
Object.assign(allProperties, objSchema.properties);
|
|
138
|
+
if (preserveRequired && objSchema.required) {
|
|
139
|
+
allRequired.push(...objSchema.required);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (!preserveRequired) {
|
|
143
|
+
allRequired = [];
|
|
144
|
+
}
|
|
145
|
+
if (Object.keys(allProperties).length === 0) {
|
|
146
|
+
return schemas[0];
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
type: 'object',
|
|
150
|
+
properties: allProperties,
|
|
151
|
+
required: allRequired
|
|
152
|
+
};
|
|
153
|
+
}
|
|
62
154
|
}
|
|
63
155
|
|
|
64
156
|
export { OperationParametersAssembler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.mjs","sources":["../../../../../../src/assemblers/document/path/path-item/operation/parameters.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport type { OpenAPIV3_1 } from 'openapi-types';\nimport type { Assembler } from '../../../..';\n\nimport type { OperationContext } from '../../../../../types';\nimport { createDebugger, zodToOpenAPI } from '../../../../../utils';\n\nconst debug = createDebugger('assembler:parameters');\n\ntype PathParameterObject = OpenAPIV3_1.ParameterObject & { in: 'path' };\ntype QueryParameterObject = OpenAPIV3_1.ParameterObject & { in: 'query' };\n\nexport class OperationParametersAssembler implements Assembler.Operation {\n assemble(context: OperationContext, route: Core.Route): void {\n debug('assembling parameters for %o %o...', route.method, route.path);\n\n const pathParameters = this._getPathParameters(route);\n debug('found %o path parameters', pathParameters.length);\n\n const queryParameters = this._getQueryParameters(route);\n debug('found %o query parameters', queryParameters.length);\n\n const parameters = [...pathParameters, ...queryParameters];\n debug('assembled %o parameters for %o %o', parameters.length, route.method, route.path);\n\n context.output.data.parameters = parameters;\n }\n\n private _getPathParameters(route: Core.Route): PathParameterObject[] {\n const { params } = route.request ?? {};\n\n // TODO: Allow auto inference (from path) if enabled through configuration\n if (!params) {\n return [];\n }\n\n const pathParams: PathParameterObject[] = [];\n\n for (const [name, zodSchema] of Object.entries(params)) {\n const required = !zodSchema.isOptional();\n const schema = zodToOpenAPI(zodSchema) as any;\n\n pathParams.push({ name, in: 'path', required, schema });\n }\n\n return pathParams;\n }\n\n private _getQueryParameters(route: Core.Route): QueryParameterObject[] {\n const { query } = route.request ?? {};\n\n if (!query) {\n return [];\n }\n\n const queryParams: QueryParameterObject[] = [];\n\n for (const [name, zodSchema] of Object.entries(query)) {\n const required = !zodSchema.isOptional();\n const schema = zodToOpenAPI(zodSchema) as any;\n const param: QueryParameterObject = { name, in: 'query', required, schema };\n\n // In Strapi, query params are always interpreted as query strings, which isn't supported by the specification\n // TODO: Make that configurable somehow\n Object.assign(param, { 'x-strapi-serialize': 'querystring' });\n\n queryParams.push(param);\n }\n\n return queryParams;\n }\n}\n"],"names":["debug","createDebugger","OperationParametersAssembler","assemble","context","route","method","path","pathParameters","_getPathParameters","length","queryParameters","_getQueryParameters","parameters","output","data","params","request","pathParams","name","zodSchema","Object","entries","required","isOptional","schema","zodToOpenAPI","push","in","query","queryParams","param","assign"],"mappings":";;;AAOA,MAAMA,QAAQC,cAAAA,CAAe,sBAAA,CAAA;AAKtB,MAAMC,4BAAAA,CAAAA;IACXC,QAAAA,CAASC,OAAyB,EAAEC,KAAiB,EAAQ;AAC3DL,QAAAA,KAAAA,CAAM,oCAAA,EAAsCK,KAAAA,CAAMC,MAAM,EAAED,MAAME,IAAI,CAAA;AAEpE,QAAA,MAAMC,cAAA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AEwB,KAAK,EAAE,GAAGxB,KAAAA,CAAMY,OAAO,IAAI,EAAC;AAEpC,QAAA,IAAI,CAACY,KAAAA,EAAO;AACV,YAAA,OAAO,EAAE;AACX,QAAA;AAEA,QAAA,MAAMC,cAAsC,EAAE;QAE9C,KAAK,MAAM,CAACX,IAAAA,EAAMC,SAAAA,CAAU,IAAIC,MAAAA,CAAOC,OAAO,CAACO,KAAAA,CAAAA,CAAQ;YACrD,MAAMN,QAAAA,GAAW,CAACH,SAAAA,CAAUI,UAAU,EAAA;AACtC,YAAA,MAAMC,SAASC,YAAAA,CAAaN,SAAAA,CAAAA;AAC5B,YAAA,MAAMW,KAAAA,GAA8B;AAAEZ,gBAAAA,IAAAA;gBAAMS,EAAAA,EAAI,OAAA;AAASL,gBAAAA,QAAAA;AAAUE,gBAAAA;AAAO,aAAA;;;YAI1EJ,MAAAA,CAAOW,MAAM,CAACD,KAAAA,EAAO;gBAAE,oBAAA,EAAsB;AAAc,aAAA,CAAA;AAE3DD,YAAAA,WAAAA,CAAYH,IAAI,CAACI,KAAAA,CAAAA;AACnB,QAAA;QAEA,OAAOD,WAAAA;AACT,IAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"parameters.mjs","sources":["../../../../../../src/assemblers/document/path/path-item/operation/parameters.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport type { OpenAPIV3_1 } from 'openapi-types';\nimport type { Assembler } from '../../../..';\n\nimport type { OperationContext } from '../../../../../types';\nimport { createDebugger, zodToOpenAPI } from '../../../../../utils';\nimport {\n hasExpandableObjectProperties,\n shouldUseDeepObjectStyle,\n} from '../../../query-param-styles';\n\nconst debug = createDebugger('assembler:parameters');\n\ntype PathParameterObject = OpenAPIV3_1.ParameterObject & { in: 'path' };\ntype QueryParameterObject = OpenAPIV3_1.ParameterObject & { in: 'query' };\n\nexport class OperationParametersAssembler implements Assembler.Operation {\n assemble(context: OperationContext, route: Core.Route): void {\n debug('assembling parameters for %o %o...', route.method, route.path);\n\n const pathParameters = this._getPathParameters(route);\n debug('found %o path parameters', pathParameters.length);\n\n const queryParameters = this._getQueryParameters(route);\n debug('found %o query parameters', queryParameters.length);\n\n const parameters = [...pathParameters, ...queryParameters];\n debug('assembled %o parameters for %o %o', parameters.length, route.method, route.path);\n\n context.output.data.parameters = parameters;\n }\n\n private _getPathParameters(route: Core.Route): PathParameterObject[] {\n const { params } = route.request ?? {};\n\n // TODO: Allow auto inference (from path) if enabled through configuration\n if (!params) {\n return [];\n }\n\n const pathParams: PathParameterObject[] = [];\n\n for (const [name, zodSchema] of Object.entries(params)) {\n const required = !zodSchema.isOptional();\n const schema = zodToOpenAPI(zodSchema) as any;\n\n pathParams.push({ name, in: 'path', required, schema });\n }\n\n return pathParams;\n }\n\n private _getQueryParameters(route: Core.Route): QueryParameterObject[] {\n const { query } = route.request ?? {};\n\n if (!query) {\n return [];\n }\n\n const queryParams: QueryParameterObject[] = [];\n\n for (const [name, zodSchema] of Object.entries(query)) {\n const required = !zodSchema.isOptional();\n const schema = zodToOpenAPI(zodSchema) as any;\n\n const resolvedSchema = this._resolveSchema(schema);\n\n if (hasExpandableObjectProperties(resolvedSchema)) {\n for (const [propName, propSchema] of Object.entries(resolvedSchema.properties!)) {\n const isRequired = resolvedSchema.required?.includes(propName) ?? false;\n\n const param: QueryParameterObject = {\n name: `${name}[${propName}]`,\n in: 'query',\n required: isRequired,\n schema: propSchema as any,\n };\n\n Object.assign(param, { 'x-strapi-serialize': 'querystring' });\n queryParams.push(param);\n }\n } else if (shouldUseDeepObjectStyle(name, resolvedSchema)) {\n const param: QueryParameterObject = {\n name,\n in: 'query',\n required,\n schema: resolvedSchema as any,\n style: 'deepObject',\n explode: true,\n };\n\n Object.assign(param, { 'x-strapi-serialize': 'querystring' });\n queryParams.push(param);\n } else {\n const param: QueryParameterObject = { name, in: 'query', required, schema };\n Object.assign(param, { 'x-strapi-serialize': 'querystring' });\n queryParams.push(param);\n }\n }\n\n return queryParams;\n }\n\n /**\n * Resolve composite OpenAPI schemas (allOf/anyOf/oneOf) into a flat object shape\n * so nested Strapi query params can be emitted as bracket notation (e.g. pagination[page]).\n */\n private _resolveSchema(schema: OpenAPIV3_1.SchemaObject): OpenAPIV3_1.SchemaObject {\n if (schema.type === 'object' && schema.properties) {\n return schema;\n }\n\n if (schema.allOf && Array.isArray(schema.allOf)) {\n const mergedSchema: OpenAPIV3_1.SchemaObject = {\n type: 'object',\n properties: {},\n required: [],\n };\n\n for (const subSchema of schema.allOf) {\n if (!('$ref' in subSchema)) {\n const hasAnyOfOneOf = Boolean(subSchema.anyOf || subSchema.oneOf);\n const resolved = this._resolveSchema(subSchema);\n\n if (resolved.type === 'object' && resolved.properties) {\n Object.assign(mergedSchema.properties!, resolved.properties);\n if (resolved.required && !hasAnyOfOneOf) {\n mergedSchema.required = [\n ...(mergedSchema.required ?? []),\n ...(resolved.required as string[]),\n ];\n }\n }\n }\n }\n\n return hasExpandableObjectProperties(mergedSchema) ? mergedSchema : schema;\n }\n\n if (schema.anyOf && Array.isArray(schema.anyOf)) {\n return this._extractCommonProperties(schema.anyOf, false);\n }\n\n if (schema.oneOf && Array.isArray(schema.oneOf)) {\n return this._extractCommonProperties(schema.oneOf, false);\n }\n\n return schema;\n }\n\n private _extractCommonProperties(\n schemas: OpenAPIV3_1.SchemaObject[],\n preserveRequired = true\n ): OpenAPIV3_1.SchemaObject {\n const objectSchemas = schemas\n .filter((s): s is OpenAPIV3_1.SchemaObject => !('$ref' in s))\n .map((s) => this._resolveSchema(s))\n .filter((s) => s.type === 'object' && s.properties);\n\n if (objectSchemas.length === 0) {\n return schemas[0] as OpenAPIV3_1.SchemaObject;\n }\n\n const allProperties: Record<string, OpenAPIV3_1.SchemaObject> = {};\n let allRequired: string[] = [];\n\n for (const objSchema of objectSchemas) {\n Object.assign(allProperties, objSchema.properties);\n if (preserveRequired && objSchema.required) {\n allRequired.push(...(objSchema.required as string[]));\n }\n }\n\n if (!preserveRequired) {\n allRequired = [];\n }\n\n if (Object.keys(allProperties).length === 0) {\n return schemas[0] as OpenAPIV3_1.SchemaObject;\n }\n\n return {\n type: 'object',\n properties: allProperties,\n required: allRequired,\n };\n }\n}\n"],"names":["debug","createDebugger","OperationParametersAssembler","assemble","context","route","method","path","pathParameters","_getPathParameters","length","queryParameters","_getQueryParameters","parameters","output","data","params","request","pathParams","name","zodSchema","Object","entries","required","isOptional","schema","zodToOpenAPI","push","in","query","queryParams","resolvedSchema","_resolveSchema","hasExpandableObjectProperties","propName","propSchema","properties","isRequired","includes","param","assign","shouldUseDeepObjectStyle","style","explode","type","allOf","Array","isArray","mergedSchema","subSchema","hasAnyOfOneOf","Boolean","anyOf","oneOf","resolved","_extractCommonProperties","schemas","preserveRequired","objectSchemas","filter","s","map","allProperties","allRequired","objSchema","keys"],"mappings":";;;;AAWA,MAAMA,QAAQC,cAAAA,CAAe,sBAAA,CAAA;AAKtB,MAAMC,4BAAAA,CAAAA;IACXC,QAAAA,CAASC,OAAyB,EAAEC,KAAiB,EAAQ;AAC3DL,QAAAA,KAAAA,CAAM,oCAAA,EAAsCK,KAAAA,CAAMC,MAAM,EAAED,MAAME,IAAI,CAAA;AAEpE,QAAA,MAAMC,cAAAA,GAAiB,IAAI,CAACC,kBAAkB,CAACJ,KAAAA,CAAAA;QAC/CL,KAAAA,CAAM,0BAAA,EAA4BQ,eAAeE,MAAM,CAAA;AAEvD,QAAA,MAAMC,eAAAA,GAAkB,IAAI,CAACC,mBAAmB,CAACP,KAAAA,CAAAA;QACjDL,KAAAA,CAAM,2BAAA,EAA6BW,gBAAgBD,MAAM,CAAA;AAEzD,QAAA,MAAMG,UAAAA,GAAa;AAAIL,YAAAA,GAAAA,cAAAA;AAAmBG,YAAAA,GAAAA;AAAgB,SAAA;QAC1DX,KAAAA,CAAM,mCAAA,EAAqCa,WAAWH,MAAM,EAAEL,MAAMC,MAAM,EAAED,MAAME,IAAI,CAAA;AAEtFH,QAAAA,OAAAA,CAAQU,MAAM,CAACC,IAAI,CAACF,UAAU,GAA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U,CAAA;YACjD,IAAIqB,gBAAAA,IAAoBO,SAAAA,CAAUzC,QAAQ,EAAE;gBAC1CwC,WAAAA,CAAYpC,IAAI,CAAA,GAAKqC,SAAAA,CAAUzC,QAAQ,CAAA;AACzC,YAAA;AACF,QAAA;AAEA,QAAA,IAAI,CAACkC,gBAAAA,EAAkB;AACrBM,YAAAA,WAAAA,GAAc,EAAE;AAClB,QAAA;AAEA,QAAA,IAAI1C,OAAO4C,IAAI,CAACH,aAAAA,CAAAA,CAAepD,MAAM,KAAK,CAAA,EAAG;YAC3C,OAAO8C,OAAO,CAAC,CAAA,CAAE;AACnB,QAAA;QAEA,OAAO;YACLZ,IAAAA,EAAM,QAAA;YACNR,UAAAA,EAAY0B,aAAAA;YACZvC,QAAAA,EAAUwC;AACZ,SAAA;AACF,IAAA;AACF;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
+
/**
|
|
3
|
+
* Query params whose values are open-ended records parsed from bracket notation
|
|
4
|
+
* (e.g. filters[title][$eq]=hello). These are described as deepObject in OpenAPI
|
|
5
|
+
* rather than expanded into fixed sub-keys.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEEP_OBJECT_QUERY_PARAMS: Set<string>;
|
|
8
|
+
export declare const shouldUseDeepObjectStyle: (name: string, schema: OpenAPIV3_1.SchemaObject) => boolean;
|
|
9
|
+
export declare const hasExpandableObjectProperties: (schema: OpenAPIV3_1.SchemaObject) => boolean;
|
|
10
|
+
//# sourceMappingURL=query-param-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-param-styles.d.ts","sourceRoot":"","sources":["../../../src/assemblers/document/query-param-styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,aAAuB,CAAC;AAE7D,eAAO,MAAM,wBAAwB,GACnC,MAAM,MAAM,EACZ,QAAQ,WAAW,CAAC,YAAY,KAC/B,OAWF,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,QAAQ,WAAW,CAAC,YAAY,KAAG,OAIhF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Query params whose values are open-ended records parsed from bracket notation
|
|
5
|
+
* (e.g. filters[title][$eq]=hello). These are described as deepObject in OpenAPI
|
|
6
|
+
* rather than expanded into fixed sub-keys.
|
|
7
|
+
*/ const DEEP_OBJECT_QUERY_PARAMS = new Set([
|
|
8
|
+
'filters'
|
|
9
|
+
]);
|
|
10
|
+
const shouldUseDeepObjectStyle = (name, schema)=>{
|
|
11
|
+
if (DEEP_OBJECT_QUERY_PARAMS.has(name)) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return schema.type === 'object' && (!schema.properties || Object.keys(schema.properties).length === 0) && schema.additionalProperties !== undefined && schema.additionalProperties !== false;
|
|
15
|
+
};
|
|
16
|
+
const hasExpandableObjectProperties = (schema)=>{
|
|
17
|
+
return Boolean(schema.type === 'object' && schema.properties && Object.keys(schema.properties).length > 0);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.DEEP_OBJECT_QUERY_PARAMS = DEEP_OBJECT_QUERY_PARAMS;
|
|
21
|
+
exports.hasExpandableObjectProperties = hasExpandableObjectProperties;
|
|
22
|
+
exports.shouldUseDeepObjectStyle = shouldUseDeepObjectStyle;
|
|
23
|
+
//# sourceMappingURL=query-param-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-param-styles.js","sources":["../../../src/assemblers/document/query-param-styles.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from 'openapi-types';\n\n/**\n * Query params whose values are open-ended records parsed from bracket notation\n * (e.g. filters[title][$eq]=hello). These are described as deepObject in OpenAPI\n * rather than expanded into fixed sub-keys.\n */\nexport const DEEP_OBJECT_QUERY_PARAMS = new Set(['filters']);\n\nexport const shouldUseDeepObjectStyle = (\n name: string,\n schema: OpenAPIV3_1.SchemaObject\n): boolean => {\n if (DEEP_OBJECT_QUERY_PARAMS.has(name)) {\n return true;\n }\n\n return (\n schema.type === 'object' &&\n (!schema.properties || Object.keys(schema.properties).length === 0) &&\n schema.additionalProperties !== undefined &&\n schema.additionalProperties !== false\n );\n};\n\nexport const hasExpandableObjectProperties = (schema: OpenAPIV3_1.SchemaObject): boolean => {\n return Boolean(\n schema.type === 'object' && schema.properties && Object.keys(schema.properties).length > 0\n );\n};\n"],"names":["DEEP_OBJECT_QUERY_PARAMS","Set","shouldUseDeepObjectStyle","name","schema","has","type","properties","Object","keys","length","additionalProperties","undefined","hasExpandableObjectProperties","Boolean"],"mappings":";;AAEA;;;;AAIC,IACM,MAAMA,wBAAAA,GAA2B,IAAIC,GAAAA,CAAI;AAAC,IAAA;CAAU;AAEpD,MAAMC,wBAAAA,GAA2B,CACtCC,IAAAA,EACAC,MAAAA,GAAAA;IAEA,IAAIJ,wBAAAA,CAAyBK,GAAG,CAACF,IAAAA,CAAAA,EAAO;QACtC,OAAO,IAAA;AACT,IAAA;IAEA,OACEC,MAAAA,CAAOE,IAAI,KAAK,QAAA,KACf,CAACF,MAAAA,CAAOG,UAAU,IAAIC,MAAAA,CAAOC,IAAI,CAACL,OAAOG,UAAU,CAAA,CAAEG,MAAM,KAAK,CAAA,CAAA,IACjEN,MAAAA,CAAOO,oBAAoB,KAAKC,SAAAA,IAChCR,MAAAA,CAAOO,oBAAoB,KAAK,KAAA;AAEpC;AAEO,MAAME,gCAAgC,CAACT,MAAAA,GAAAA;AAC5C,IAAA,OAAOU,OAAAA,CACLV,MAAAA,CAAOE,IAAI,KAAK,YAAYF,MAAAA,CAAOG,UAAU,IAAIC,MAAAA,CAAOC,IAAI,CAACL,MAAAA,CAAOG,UAAU,CAAA,CAAEG,MAAM,GAAG,CAAA,CAAA;AAE7F;;;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query params whose values are open-ended records parsed from bracket notation
|
|
3
|
+
* (e.g. filters[title][$eq]=hello). These are described as deepObject in OpenAPI
|
|
4
|
+
* rather than expanded into fixed sub-keys.
|
|
5
|
+
*/ const DEEP_OBJECT_QUERY_PARAMS = new Set([
|
|
6
|
+
'filters'
|
|
7
|
+
]);
|
|
8
|
+
const shouldUseDeepObjectStyle = (name, schema)=>{
|
|
9
|
+
if (DEEP_OBJECT_QUERY_PARAMS.has(name)) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return schema.type === 'object' && (!schema.properties || Object.keys(schema.properties).length === 0) && schema.additionalProperties !== undefined && schema.additionalProperties !== false;
|
|
13
|
+
};
|
|
14
|
+
const hasExpandableObjectProperties = (schema)=>{
|
|
15
|
+
return Boolean(schema.type === 'object' && schema.properties && Object.keys(schema.properties).length > 0);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { DEEP_OBJECT_QUERY_PARAMS, hasExpandableObjectProperties, shouldUseDeepObjectStyle };
|
|
19
|
+
//# sourceMappingURL=query-param-styles.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-param-styles.mjs","sources":["../../../src/assemblers/document/query-param-styles.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from 'openapi-types';\n\n/**\n * Query params whose values are open-ended records parsed from bracket notation\n * (e.g. filters[title][$eq]=hello). These are described as deepObject in OpenAPI\n * rather than expanded into fixed sub-keys.\n */\nexport const DEEP_OBJECT_QUERY_PARAMS = new Set(['filters']);\n\nexport const shouldUseDeepObjectStyle = (\n name: string,\n schema: OpenAPIV3_1.SchemaObject\n): boolean => {\n if (DEEP_OBJECT_QUERY_PARAMS.has(name)) {\n return true;\n }\n\n return (\n schema.type === 'object' &&\n (!schema.properties || Object.keys(schema.properties).length === 0) &&\n schema.additionalProperties !== undefined &&\n schema.additionalProperties !== false\n );\n};\n\nexport const hasExpandableObjectProperties = (schema: OpenAPIV3_1.SchemaObject): boolean => {\n return Boolean(\n schema.type === 'object' && schema.properties && Object.keys(schema.properties).length > 0\n );\n};\n"],"names":["DEEP_OBJECT_QUERY_PARAMS","Set","shouldUseDeepObjectStyle","name","schema","has","type","properties","Object","keys","length","additionalProperties","undefined","hasExpandableObjectProperties","Boolean"],"mappings":"AAEA;;;;AAIC,IACM,MAAMA,wBAAAA,GAA2B,IAAIC,GAAAA,CAAI;AAAC,IAAA;CAAU;AAEpD,MAAMC,wBAAAA,GAA2B,CACtCC,IAAAA,EACAC,MAAAA,GAAAA;IAEA,IAAIJ,wBAAAA,CAAyBK,GAAG,CAACF,IAAAA,CAAAA,EAAO;QACtC,OAAO,IAAA;AACT,IAAA;IAEA,OACEC,MAAAA,CAAOE,IAAI,KAAK,QAAA,KACf,CAACF,MAAAA,CAAOG,UAAU,IAAIC,MAAAA,CAAOC,IAAI,CAACL,OAAOG,UAAU,CAAA,CAAEG,MAAM,KAAK,CAAA,CAAA,IACjEN,MAAAA,CAAOO,oBAAoB,KAAKC,SAAAA,IAChCR,MAAAA,CAAOO,oBAAoB,KAAK,KAAA;AAEpC;AAEO,MAAME,gCAAgC,CAACT,MAAAA,GAAAA;AAC5C,IAAA,OAAOU,OAAAA,CACLV,MAAAA,CAAOE,IAAI,KAAK,YAAYF,MAAAA,CAAOG,UAAU,IAAIC,MAAAA,CAAOC,IAAI,CAACL,MAAAA,CAAOG,UAAU,CAAA,CAAEG,MAAM,GAAG,CAAA,CAAA;AAE7F;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DocumentContext } from '../../types';
|
|
2
|
+
import type { Assembler } from '..';
|
|
3
|
+
export declare class DocumentSecurityAssembler implements Assembler.Document {
|
|
4
|
+
assemble(context: DocumentContext): void;
|
|
5
|
+
private _getSecuritySchemes;
|
|
6
|
+
private _getGlobalSecurity;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../src/assemblers/document/security.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AASpC,qBAAa,yBAA0B,YAAW,SAAS,CAAC,QAAQ;IAClE,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAcxC,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,kBAAkB;CAU3B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_BEARER_AUTH = {
|
|
4
|
+
type: 'http',
|
|
5
|
+
scheme: 'bearer',
|
|
6
|
+
bearerFormat: 'JWT',
|
|
7
|
+
description: 'JWT Bearer token for authentication'
|
|
8
|
+
};
|
|
9
|
+
class DocumentSecurityAssembler {
|
|
10
|
+
assemble(context) {
|
|
11
|
+
const { strapi } = context;
|
|
12
|
+
const securitySchemes = this._getSecuritySchemes(strapi);
|
|
13
|
+
const security = this._getGlobalSecurity(strapi);
|
|
14
|
+
if (context.output.data.components === undefined) {
|
|
15
|
+
context.output.data.components = {};
|
|
16
|
+
}
|
|
17
|
+
context.output.data.components.securitySchemes = securitySchemes;
|
|
18
|
+
context.output.data.security = security;
|
|
19
|
+
}
|
|
20
|
+
_getSecuritySchemes(strapi) {
|
|
21
|
+
const securityConfig = strapi.config.get('openapi.security') ?? {};
|
|
22
|
+
const schemes = {};
|
|
23
|
+
if (!securityConfig.bearerAuth) {
|
|
24
|
+
schemes.bearerAuth = DEFAULT_BEARER_AUTH;
|
|
25
|
+
}
|
|
26
|
+
for (const [name, config] of Object.entries(securityConfig)){
|
|
27
|
+
schemes[name] = config;
|
|
28
|
+
}
|
|
29
|
+
return schemes;
|
|
30
|
+
}
|
|
31
|
+
_getGlobalSecurity(strapi) {
|
|
32
|
+
const globalSecurity = strapi.config.get('openapi.globalSecurity');
|
|
33
|
+
if (globalSecurity) {
|
|
34
|
+
return globalSecurity;
|
|
35
|
+
}
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
bearerAuth: []
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.DocumentSecurityAssembler = DocumentSecurityAssembler;
|
|
45
|
+
//# sourceMappingURL=security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","sources":["../../../src/assemblers/document/security.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\nimport type { DocumentContext } from '../../types';\n\nimport type { Assembler } from '..';\n\nconst DEFAULT_BEARER_AUTH: OpenAPIV3_1.HttpSecurityScheme = {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n description: 'JWT Bearer token for authentication',\n};\n\nexport class DocumentSecurityAssembler implements Assembler.Document {\n assemble(context: DocumentContext): void {\n const { strapi } = context;\n\n const securitySchemes = this._getSecuritySchemes(strapi);\n const security = this._getGlobalSecurity(strapi);\n\n if (context.output.data.components === undefined) {\n context.output.data.components = {};\n }\n\n context.output.data.components.securitySchemes = securitySchemes;\n context.output.data.security = security;\n }\n\n private _getSecuritySchemes(\n strapi: Core.Strapi\n ): Record<string, OpenAPIV3_1.SecuritySchemeObject> {\n const securityConfig =\n strapi.config.get<\n Record<string, OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SecuritySchemeObject>\n >('openapi.security') ?? {};\n\n const schemes: Record<string, OpenAPIV3_1.SecuritySchemeObject> = {};\n\n if (!securityConfig.bearerAuth) {\n schemes.bearerAuth = DEFAULT_BEARER_AUTH;\n }\n\n for (const [name, config] of Object.entries(securityConfig)) {\n schemes[name] = config as OpenAPIV3_1.SecuritySchemeObject;\n }\n\n return schemes;\n }\n\n private _getGlobalSecurity(strapi: Core.Strapi): OpenAPIV3_1.Document['security'] {\n const globalSecurity =\n strapi.config.get<OpenAPIV3_1.Document['security']>('openapi.globalSecurity');\n\n if (globalSecurity) {\n return globalSecurity;\n }\n\n return [{ bearerAuth: [] }];\n }\n}\n"],"names":["DEFAULT_BEARER_AUTH","type","scheme","bearerFormat","description","DocumentSecurityAssembler","assemble","context","strapi","securitySchemes","_getSecuritySchemes","security","_getGlobalSecurity","output","data","components","undefined","securityConfig","config","get","schemes","bearerAuth","name","Object","entries","globalSecurity"],"mappings":";;AAOA,MAAMA,mBAAAA,GAAsD;IAC1DC,IAAAA,EAAM,MAAA;IACNC,MAAAA,EAAQ,QAAA;IACRC,YAAAA,EAAc,KAAA;IACdC,WAAAA,EAAa;AACf,CAAA;AAEO,MAAMC,yBAAAA,CAAAA;AACXC,IAAAA,QAAAA,CAASC,OAAwB,EAAQ;QACvC,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAAA;AAEnB,QAAA,MAAME,eAAAA,GAAkB,IAAI,CAACC,mBAAmB,CAACF,MAAAA,CAAAA;AACjD,QAAA,MAAMG,QAAAA,GAAW,IAAI,CAACC,kBAAkB,CAACJ,MAAAA,CAAAA;AAEzC,QAAA,IAAID,QAAQM,MAAM,CAACC,IAAI,CAACC,UAAU,KAAKC,SAAAA,EAAW;AAChDT,YAAAA,OAAAA,CAAQM,MAAM,CAACC,IAAI,CAACC,UAAU,GAAG,EAAC;AACpC,QAAA;AAEAR,QAAAA,OAAAA,CAAQM,MAAM,CAACC,IAAI,CAACC,UAAU,CAACN,eAAe,GAAGA,eAAAA;AACjDF,QAAAA,OAAAA,CAAQM,MAAM,CAACC,IAAI,CAACH,QAAQ,GAAGA,QAAAA;AACjC,IAAA;AAEQD,IAAAA,mBAAAA,CACNF,MAAmB,EAC+B;AAClD,QAAA,MAAMS,iBACJT,MAAAA,CAAOU,MAAM,CAACC,GAAG,CAEf,uBAAuB,EAAC;AAE5B,QAAA,MAAMC,UAA4D,EAAC;QAEnE,IAAI,CAACH,cAAAA,CAAeI,UAAU,EAAE;AAC9BD,YAAAA,OAAAA,CAAQC,UAAU,GAAGrB,mBAAAA;AACvB,QAAA;QAEA,KAAK,MAAM,CAACsB,IAAAA,EAAMJ,MAAAA,CAAO,IAAIK,MAAAA,CAAOC,OAAO,CAACP,cAAAA,CAAAA,CAAiB;YAC3DG,OAAO,CAACE,KAAK,GAAGJ,MAAAA;AAClB,QAAA;QAEA,OAAOE,OAAAA;AACT,IAAA;AAEQR,IAAAA,kBAAAA,CAAmBJ,MAAmB,EAAoC;AAChF,QAAA,MAAMiB,cAAAA,GACJjB,MAAAA,CAAOU,MAAM,CAACC,GAAG,CAAmC,wBAAA,CAAA;AAEtD,QAAA,IAAIM,cAAAA,EAAgB;YAClB,OAAOA,cAAAA;AACT,QAAA;QAEA,OAAO;AAAC,YAAA;AAAEJ,gBAAAA,UAAAA,EAAY;AAAG;AAAE,SAAA;AAC7B,IAAA;AACF;;;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const DEFAULT_BEARER_AUTH = {
|
|
2
|
+
type: 'http',
|
|
3
|
+
scheme: 'bearer',
|
|
4
|
+
bearerFormat: 'JWT',
|
|
5
|
+
description: 'JWT Bearer token for authentication'
|
|
6
|
+
};
|
|
7
|
+
class DocumentSecurityAssembler {
|
|
8
|
+
assemble(context) {
|
|
9
|
+
const { strapi } = context;
|
|
10
|
+
const securitySchemes = this._getSecuritySchemes(strapi);
|
|
11
|
+
const security = this._getGlobalSecurity(strapi);
|
|
12
|
+
if (context.output.data.components === undefined) {
|
|
13
|
+
context.output.data.components = {};
|
|
14
|
+
}
|
|
15
|
+
context.output.data.components.securitySchemes = securitySchemes;
|
|
16
|
+
context.output.data.security = security;
|
|
17
|
+
}
|
|
18
|
+
_getSecuritySchemes(strapi) {
|
|
19
|
+
const securityConfig = strapi.config.get('openapi.security') ?? {};
|
|
20
|
+
const schemes = {};
|
|
21
|
+
if (!securityConfig.bearerAuth) {
|
|
22
|
+
schemes.bearerAuth = DEFAULT_BEARER_AUTH;
|
|
23
|
+
}
|
|
24
|
+
for (const [name, config] of Object.entries(securityConfig)){
|
|
25
|
+
schemes[name] = config;
|
|
26
|
+
}
|
|
27
|
+
return schemes;
|
|
28
|
+
}
|
|
29
|
+
_getGlobalSecurity(strapi) {
|
|
30
|
+
const globalSecurity = strapi.config.get('openapi.globalSecurity');
|
|
31
|
+
if (globalSecurity) {
|
|
32
|
+
return globalSecurity;
|
|
33
|
+
}
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
bearerAuth: []
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { DocumentSecurityAssembler };
|
|
43
|
+
//# sourceMappingURL=security.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.mjs","sources":["../../../src/assemblers/document/security.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\nimport type { DocumentContext } from '../../types';\n\nimport type { Assembler } from '..';\n\nconst DEFAULT_BEARER_AUTH: OpenAPIV3_1.HttpSecurityScheme = {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n description: 'JWT Bearer token for authentication',\n};\n\nexport class DocumentSecurityAssembler implements Assembler.Document {\n assemble(context: DocumentContext): void {\n const { strapi } = context;\n\n const securitySchemes = this._getSecuritySchemes(strapi);\n const security = this._getGlobalSecurity(strapi);\n\n if (context.output.data.components === undefined) {\n context.output.data.components = {};\n }\n\n context.output.data.components.securitySchemes = securitySchemes;\n context.output.data.security = security;\n }\n\n private _getSecuritySchemes(\n strapi: Core.Strapi\n ): Record<string, OpenAPIV3_1.SecuritySchemeObject> {\n const securityConfig =\n strapi.config.get<\n Record<string, OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SecuritySchemeObject>\n >('openapi.security') ?? {};\n\n const schemes: Record<string, OpenAPIV3_1.SecuritySchemeObject> = {};\n\n if (!securityConfig.bearerAuth) {\n schemes.bearerAuth = DEFAULT_BEARER_AUTH;\n }\n\n for (const [name, config] of Object.entries(securityConfig)) {\n schemes[name] = config as OpenAPIV3_1.SecuritySchemeObject;\n }\n\n return schemes;\n }\n\n private _getGlobalSecurity(strapi: Core.Strapi): OpenAPIV3_1.Document['security'] {\n const globalSecurity =\n strapi.config.get<OpenAPIV3_1.Document['security']>('openapi.globalSecurity');\n\n if (globalSecurity) {\n return globalSecurity;\n }\n\n return [{ bearerAuth: [] }];\n }\n}\n"],"names":["DEFAULT_BEARER_AUTH","type","scheme","bearerFormat","description","DocumentSecurityAssembler","assemble","context","strapi","securitySchemes","_getSecuritySchemes","security","_getGlobalSecurity","output","data","components","undefined","securityConfig","config","get","schemes","bearerAuth","name","Object","entries","globalSecurity"],"mappings":"AAOA,MAAMA,mBAAAA,GAAsD;IAC1DC,IAAAA,EAAM,MAAA;IACNC,MAAAA,EAAQ,QAAA;IACRC,YAAAA,EAAc,KAAA;IACdC,WAAAA,EAAa;AACf,CAAA;AAEO,MAAMC,yBAAAA,CAAAA;AACXC,IAAAA,QAAAA,CAASC,OAAwB,EAAQ;QACvC,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAAA;AAEnB,QAAA,MAAME,eAAAA,GAAkB,IAAI,CAACC,mBAAmB,CAACF,MAAAA,CAAAA;AACjD,QAAA,MAAMG,QAAAA,GAAW,IAAI,CAACC,kBAAkB,CAACJ,MAAAA,CAAAA;AAEzC,QAAA,IAAID,QAAQM,MAAM,CAACC,IAAI,CAACC,UAAU,KAAKC,SAAAA,EAAW;AAChDT,YAAAA,OAAAA,CAAQM,MAAM,CAACC,IAAI,CAACC,UAAU,GAAG,EAAC;AACpC,QAAA;AAEAR,QAAAA,OAAAA,CAAQM,MAAM,CAACC,IAAI,CAACC,UAAU,CAACN,eAAe,GAAGA,eAAAA;AACjDF,QAAAA,OAAAA,CAAQM,MAAM,CAACC,IAAI,CAACH,QAAQ,GAAGA,QAAAA;AACjC,IAAA;AAEQD,IAAAA,mBAAAA,CACNF,MAAmB,EAC+B;AAClD,QAAA,MAAMS,iBACJT,MAAAA,CAAOU,MAAM,CAACC,GAAG,CAEf,uBAAuB,EAAC;AAE5B,QAAA,MAAMC,UAA4D,EAAC;QAEnE,IAAI,CAACH,cAAAA,CAAeI,UAAU,EAAE;AAC9BD,YAAAA,OAAAA,CAAQC,UAAU,GAAGrB,mBAAAA;AACvB,QAAA;QAEA,KAAK,MAAM,CAACsB,IAAAA,EAAMJ,MAAAA,CAAO,IAAIK,MAAAA,CAAOC,OAAO,CAACP,cAAAA,CAAAA,CAAiB;YAC3DG,OAAO,CAACE,KAAK,GAAGJ,MAAAA;AAClB,QAAA;QAEA,OAAOE,OAAAA;AACT,IAAA;AAEQR,IAAAA,kBAAAA,CAAmBJ,MAAmB,EAAoC;AAChF,QAAA,MAAMiB,cAAAA,GACJjB,MAAAA,CAAOU,MAAM,CAACC,GAAG,CAAmC,wBAAA,CAAA;AAEtD,QAAA,IAAIM,cAAAA,EAAgB;YAClB,OAAOA,cAAAA;AACT,QAAA;QAEA,OAAO;AAAC,YAAA;AAAEJ,gBAAAA,UAAAA,EAAY;AAAG;AAAE,SAAA;AAC7B,IAAA;AACF;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
+
import type { DocumentContext } from '../../types';
|
|
3
|
+
import type { Assembler } from '..';
|
|
4
|
+
export interface ServerConfig {
|
|
5
|
+
url: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
variables?: Record<string, OpenAPIV3_1.ServerVariableObject>;
|
|
8
|
+
}
|
|
9
|
+
export declare class DocumentServerAssembler implements Assembler.Document {
|
|
10
|
+
assemble(context: DocumentContext): void;
|
|
11
|
+
private _getServers;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/assemblers/document/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAEpC,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,oBAAoB,CAAC,CAAC;CAC9D;AAID,qBAAa,uBAAwB,YAAW,SAAS,CAAC,QAAQ;IAChE,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAMxC,OAAO,CAAC,WAAW;CAgBpB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_SERVER_URL = 'http://localhost:1337';
|
|
4
|
+
class DocumentServerAssembler {
|
|
5
|
+
assemble(context) {
|
|
6
|
+
const { strapi } = context;
|
|
7
|
+
context.output.data.servers = this._getServers(strapi);
|
|
8
|
+
}
|
|
9
|
+
_getServers(strapi) {
|
|
10
|
+
const serverConfig = strapi.config.get('openapi.servers') ?? [];
|
|
11
|
+
if (serverConfig.length > 0) {
|
|
12
|
+
return serverConfig;
|
|
13
|
+
}
|
|
14
|
+
const serverUrl = strapi.config.get('server.url') ?? DEFAULT_SERVER_URL;
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
url: serverUrl,
|
|
18
|
+
description: 'Default server'
|
|
19
|
+
}
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.DocumentServerAssembler = DocumentServerAssembler;
|
|
25
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sources":["../../../src/assemblers/document/server.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from 'openapi-types';\n\nimport type { Core } from '@strapi/types';\nimport type { DocumentContext } from '../../types';\n\nimport type { Assembler } from '..';\n\nexport interface ServerConfig {\n url: string;\n description?: string;\n variables?: Record<string, OpenAPIV3_1.ServerVariableObject>;\n}\n\nconst DEFAULT_SERVER_URL = 'http://localhost:1337';\n\nexport class DocumentServerAssembler implements Assembler.Document {\n assemble(context: DocumentContext): void {\n const { strapi } = context;\n\n context.output.data.servers = this._getServers(strapi);\n }\n\n private _getServers(strapi: Core.Strapi): OpenAPIV3_1.ServerObject[] {\n const serverConfig = strapi.config.get<ServerConfig[]>('openapi.servers') ?? [];\n\n if (serverConfig.length > 0) {\n return serverConfig;\n }\n\n const serverUrl = strapi.config.get<string>('server.url') ?? DEFAULT_SERVER_URL;\n\n return [\n {\n url: serverUrl,\n description: 'Default server',\n },\n ];\n }\n}\n"],"names":["DEFAULT_SERVER_URL","DocumentServerAssembler","assemble","context","strapi","output","data","servers","_getServers","serverConfig","config","get","length","serverUrl","url","description"],"mappings":";;AAaA,MAAMA,kBAAAA,GAAqB,uBAAA;AAEpB,MAAMC,uBAAAA,CAAAA;AACXC,IAAAA,QAAAA,CAASC,OAAwB,EAAQ;QACvC,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAAA;QAEnBA,OAAAA,CAAQE,MAAM,CAACC,IAAI,CAACC,OAAO,GAAG,IAAI,CAACC,WAAW,CAACJ,MAAAA,CAAAA;AACjD,IAAA;AAEQI,IAAAA,WAAAA,CAAYJ,MAAmB,EAA8B;AACnE,QAAA,MAAMK,eAAeL,MAAAA,CAAOM,MAAM,CAACC,GAAG,CAAiB,sBAAsB,EAAE;QAE/E,IAAIF,YAAAA,CAAaG,MAAM,GAAG,CAAA,EAAG;YAC3B,OAAOH,YAAAA;AACT,QAAA;AAEA,QAAA,MAAMI,YAAYT,MAAAA,CAAOM,MAAM,CAACC,GAAG,CAAS,YAAA,CAAA,IAAiBX,kBAAAA;QAE7D,OAAO;AACL,YAAA;gBACEc,GAAAA,EAAKD,SAAAA;gBACLE,WAAAA,EAAa;AACf;AACD,SAAA;AACH,IAAA;AACF;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const DEFAULT_SERVER_URL = 'http://localhost:1337';
|
|
2
|
+
class DocumentServerAssembler {
|
|
3
|
+
assemble(context) {
|
|
4
|
+
const { strapi } = context;
|
|
5
|
+
context.output.data.servers = this._getServers(strapi);
|
|
6
|
+
}
|
|
7
|
+
_getServers(strapi) {
|
|
8
|
+
const serverConfig = strapi.config.get('openapi.servers') ?? [];
|
|
9
|
+
if (serverConfig.length > 0) {
|
|
10
|
+
return serverConfig;
|
|
11
|
+
}
|
|
12
|
+
const serverUrl = strapi.config.get('server.url') ?? DEFAULT_SERVER_URL;
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
url: serverUrl,
|
|
16
|
+
description: 'Default server'
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { DocumentServerAssembler };
|
|
23
|
+
//# sourceMappingURL=server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.mjs","sources":["../../../src/assemblers/document/server.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from 'openapi-types';\n\nimport type { Core } from '@strapi/types';\nimport type { DocumentContext } from '../../types';\n\nimport type { Assembler } from '..';\n\nexport interface ServerConfig {\n url: string;\n description?: string;\n variables?: Record<string, OpenAPIV3_1.ServerVariableObject>;\n}\n\nconst DEFAULT_SERVER_URL = 'http://localhost:1337';\n\nexport class DocumentServerAssembler implements Assembler.Document {\n assemble(context: DocumentContext): void {\n const { strapi } = context;\n\n context.output.data.servers = this._getServers(strapi);\n }\n\n private _getServers(strapi: Core.Strapi): OpenAPIV3_1.ServerObject[] {\n const serverConfig = strapi.config.get<ServerConfig[]>('openapi.servers') ?? [];\n\n if (serverConfig.length > 0) {\n return serverConfig;\n }\n\n const serverUrl = strapi.config.get<string>('server.url') ?? DEFAULT_SERVER_URL;\n\n return [\n {\n url: serverUrl,\n description: 'Default server',\n },\n ];\n }\n}\n"],"names":["DEFAULT_SERVER_URL","DocumentServerAssembler","assemble","context","strapi","output","data","servers","_getServers","serverConfig","config","get","length","serverUrl","url","description"],"mappings":"AAaA,MAAMA,kBAAAA,GAAqB,uBAAA;AAEpB,MAAMC,uBAAAA,CAAAA;AACXC,IAAAA,QAAAA,CAASC,OAAwB,EAAQ;QACvC,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAAA;QAEnBA,OAAAA,CAAQE,MAAM,CAACC,IAAI,CAACC,OAAO,GAAG,IAAI,CAACC,WAAW,CAACJ,MAAAA,CAAAA;AACjD,IAAA;AAEQI,IAAAA,WAAAA,CAAYJ,MAAmB,EAA8B;AACnE,QAAA,MAAMK,eAAeL,MAAAA,CAAOM,MAAM,CAACC,GAAG,CAAiB,sBAAsB,EAAE;QAE/E,IAAIF,YAAAA,CAAaG,MAAM,GAAG,CAAA,EAAG;YAC3B,OAAOH,YAAAA;AACT,QAAA;AAEA,QAAA,MAAMI,YAAYT,MAAAA,CAAOM,MAAM,CAACC,GAAG,CAAS,YAAA,CAAA,IAAiBX,kBAAAA;QAE7D,OAAO;AACL,YAAA;gBACEc,GAAAA,EAAKD,SAAAA;gBACLE,WAAAA,EAAa;AACf;AACD,SAAA;AACH,IAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-writer.d.ts","sourceRoot":"","sources":["../../src/post-processor/component-writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAAa,gBAAiB,YAAW,aAAa;IACpD,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"component-writer.d.ts","sourceRoot":"","sources":["../../src/post-processor/component-writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAAa,gBAAiB,YAAW,aAAa;IACpD,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;CAoB5C"}
|
|
@@ -29,7 +29,14 @@ class ComponentsWriter {
|
|
|
29
29
|
const { schemas } = z__namespace.toJSONSchema(z__namespace.globalRegistry, {
|
|
30
30
|
uri: zod.toComponentsPath
|
|
31
31
|
});
|
|
32
|
+
for (const schema of Object.values(schemas ?? {})){
|
|
33
|
+
if (schema && typeof schema === 'object') {
|
|
34
|
+
zod.stripJsonSchemaId(schema);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const existingComponents = output.data.components ?? {};
|
|
32
38
|
output.data.components = {
|
|
39
|
+
...existingComponents,
|
|
33
40
|
schemas
|
|
34
41
|
};
|
|
35
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-writer.js","sources":["../../src/post-processor/component-writer.ts"],"sourcesContent":["import { OpenAPIV3_1 } from 'openapi-types';\nimport * as z from 'zod/v4';\nimport type { DocumentContext } from '../types';\nimport { toComponentsPath } from '../utils/zod';\nimport type { PostProcessor } from './types';\n\nexport class ComponentsWriter implements PostProcessor {\n postProcess(context: DocumentContext): void {\n const { output } = context;\n\n const { schemas } = z.toJSONSchema(z.globalRegistry, {\n uri: toComponentsPath,\n }) as OpenAPIV3_1.ComponentsObject;\n\n output.data.components = {
|
|
1
|
+
{"version":3,"file":"component-writer.js","sources":["../../src/post-processor/component-writer.ts"],"sourcesContent":["import { OpenAPIV3_1 } from 'openapi-types';\nimport * as z from 'zod/v4';\nimport type { DocumentContext } from '../types';\nimport { stripJsonSchemaId, toComponentsPath } from '../utils/zod';\nimport type { PostProcessor } from './types';\n\nexport class ComponentsWriter implements PostProcessor {\n postProcess(context: DocumentContext): void {\n const { output } = context;\n\n const { schemas } = z.toJSONSchema(z.globalRegistry, {\n uri: toComponentsPath,\n }) as OpenAPIV3_1.ComponentsObject;\n\n for (const schema of Object.values(schemas ?? {})) {\n if (schema && typeof schema === 'object') {\n stripJsonSchemaId(schema);\n }\n }\n\n const existingComponents = output.data.components ?? {};\n\n output.data.components = {\n ...existingComponents,\n schemas,\n };\n }\n}\n"],"names":["ComponentsWriter","postProcess","context","output","schemas","z","toJSONSchema","globalRegistry","uri","toComponentsPath","schema","Object","values","stripJsonSchemaId","existingComponents","data","components"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMO,MAAMA,gBAAAA,CAAAA;AACXC,IAAAA,WAAAA,CAAYC,OAAwB,EAAQ;QAC1C,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAAA;QAEnB,MAAM,EAAEE,OAAO,EAAE,GAAGC,aAAEC,YAAY,CAACD,YAAAA,CAAEE,cAAc,EAAE;YACnDC,GAAAA,EAAKC;AACP,SAAA,CAAA;AAEA,QAAA,KAAK,MAAMC,MAAAA,IAAUC,MAAAA,CAAOC,MAAM,CAACR,OAAAA,IAAW,EAAC,CAAA,CAAI;YACjD,IAAIM,MAAAA,IAAU,OAAOA,MAAAA,KAAW,QAAA,EAAU;gBACxCG,qBAAAA,CAAkBH,MAAAA,CAAAA;AACpB,YAAA;AACF,QAAA;AAEA,QAAA,MAAMI,qBAAqBX,MAAAA,CAAOY,IAAI,CAACC,UAAU,IAAI,EAAC;QAEtDb,MAAAA,CAAOY,IAAI,CAACC,UAAU,GAAG;AACvB,YAAA,GAAGF,kBAAkB;AACrBV,YAAAA;AACF,SAAA;AACF,IAAA;AACF;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod/v4';
|
|
2
|
-
import { toComponentsPath } from '../utils/zod.mjs';
|
|
2
|
+
import { toComponentsPath, stripJsonSchemaId } from '../utils/zod.mjs';
|
|
3
3
|
|
|
4
4
|
class ComponentsWriter {
|
|
5
5
|
postProcess(context) {
|
|
@@ -7,7 +7,14 @@ class ComponentsWriter {
|
|
|
7
7
|
const { schemas } = z.toJSONSchema(z.globalRegistry, {
|
|
8
8
|
uri: toComponentsPath
|
|
9
9
|
});
|
|
10
|
+
for (const schema of Object.values(schemas ?? {})){
|
|
11
|
+
if (schema && typeof schema === 'object') {
|
|
12
|
+
stripJsonSchemaId(schema);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const existingComponents = output.data.components ?? {};
|
|
10
16
|
output.data.components = {
|
|
17
|
+
...existingComponents,
|
|
11
18
|
schemas
|
|
12
19
|
};
|
|
13
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-writer.mjs","sources":["../../src/post-processor/component-writer.ts"],"sourcesContent":["import { OpenAPIV3_1 } from 'openapi-types';\nimport * as z from 'zod/v4';\nimport type { DocumentContext } from '../types';\nimport { toComponentsPath } from '../utils/zod';\nimport type { PostProcessor } from './types';\n\nexport class ComponentsWriter implements PostProcessor {\n postProcess(context: DocumentContext): void {\n const { output } = context;\n\n const { schemas } = z.toJSONSchema(z.globalRegistry, {\n uri: toComponentsPath,\n }) as OpenAPIV3_1.ComponentsObject;\n\n output.data.components = {
|
|
1
|
+
{"version":3,"file":"component-writer.mjs","sources":["../../src/post-processor/component-writer.ts"],"sourcesContent":["import { OpenAPIV3_1 } from 'openapi-types';\nimport * as z from 'zod/v4';\nimport type { DocumentContext } from '../types';\nimport { stripJsonSchemaId, toComponentsPath } from '../utils/zod';\nimport type { PostProcessor } from './types';\n\nexport class ComponentsWriter implements PostProcessor {\n postProcess(context: DocumentContext): void {\n const { output } = context;\n\n const { schemas } = z.toJSONSchema(z.globalRegistry, {\n uri: toComponentsPath,\n }) as OpenAPIV3_1.ComponentsObject;\n\n for (const schema of Object.values(schemas ?? {})) {\n if (schema && typeof schema === 'object') {\n stripJsonSchemaId(schema);\n }\n }\n\n const existingComponents = output.data.components ?? {};\n\n output.data.components = {\n ...existingComponents,\n schemas,\n };\n }\n}\n"],"names":["ComponentsWriter","postProcess","context","output","schemas","z","toJSONSchema","globalRegistry","uri","toComponentsPath","schema","Object","values","stripJsonSchemaId","existingComponents","data","components"],"mappings":";;;AAMO,MAAMA,gBAAAA,CAAAA;AACXC,IAAAA,WAAAA,CAAYC,OAAwB,EAAQ;QAC1C,MAAM,EAAEC,MAAM,EAAE,GAAGD,OAAAA;QAEnB,MAAM,EAAEE,OAAO,EAAE,GAAGC,EAAEC,YAAY,CAACD,CAAAA,CAAEE,cAAc,EAAE;YACnDC,GAAAA,EAAKC;AACP,SAAA,CAAA;AAEA,QAAA,KAAK,MAAMC,MAAAA,IAAUC,MAAAA,CAAOC,MAAM,CAACR,OAAAA,IAAW,EAAC,CAAA,CAAI;YACjD,IAAIM,MAAAA,IAAU,OAAOA,MAAAA,KAAW,QAAA,EAAU;gBACxCG,iBAAAA,CAAkBH,MAAAA,CAAAA;AACpB,YAAA;AACF,QAAA;AAEA,QAAA,MAAMI,qBAAqBX,MAAAA,CAAOY,IAAI,CAACC,UAAU,IAAI,EAAC;QAEtDb,MAAAA,CAAOY,IAAI,CAACC,UAAU,GAAG;AACvB,YAAA,GAAGF,kBAAkB;AACrBV,YAAAA;AACF,SAAA;AACF,IAAA;AACF;;;;"}
|
package/dist/utils/zod.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as z from 'zod/v4';
|
|
2
2
|
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
3
|
+
/**
|
|
4
|
+
* Zod ≥3.25.76 embeds `$id` in `toJSONSchema` output (set after `override`).
|
|
5
|
+
* Strip it so OpenAPI documents stay stable — inline schemas use random UUIDs
|
|
6
|
+
* as registry ids — and match the pre-3.25.76 shape.
|
|
7
|
+
*/
|
|
8
|
+
export declare const stripJsonSchemaId: <T extends object>(schema: T) => T;
|
|
3
9
|
/**
|
|
4
10
|
* Converts a Zod schema to an OpenAPI Schema Object.
|
|
5
11
|
*
|
package/dist/utils/zod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/utils/zod.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/utils/zod.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,MAAM,EAAE,QAAQ,CAAC,KAAG,CAK/D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,YAAY,GACvB,WAAW,CAAC,CAAC,OAAO,KACnB,WAAW,CAAC,YAAY,GAAG,WAAW,CAAC,eAsBzC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,IAAI,MAAM,WAAiC,CAAC"}
|
package/dist/utils/zod.js
CHANGED
|
@@ -23,6 +23,16 @@ function _interopNamespace(e) {
|
|
|
23
23
|
|
|
24
24
|
var z__namespace = /*#__PURE__*/_interopNamespace(z);
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Zod ≥3.25.76 embeds `$id` in `toJSONSchema` output (set after `override`).
|
|
28
|
+
* Strip it so OpenAPI documents stay stable — inline schemas use random UUIDs
|
|
29
|
+
* as registry ids — and match the pre-3.25.76 shape.
|
|
30
|
+
*/ const stripJsonSchemaId = (schema)=>{
|
|
31
|
+
if ('$id' in schema) {
|
|
32
|
+
delete schema.$id;
|
|
33
|
+
}
|
|
34
|
+
return schema;
|
|
35
|
+
};
|
|
26
36
|
/**
|
|
27
37
|
* Converts a Zod schema to an OpenAPI Schema Object.
|
|
28
38
|
*
|
|
@@ -70,7 +80,7 @@ var z__namespace = /*#__PURE__*/_interopNamespace(z);
|
|
|
70
80
|
uri: toComponentsPath
|
|
71
81
|
});
|
|
72
82
|
// TODO: make sure it's compliant
|
|
73
|
-
return schemas[id];
|
|
83
|
+
return stripJsonSchemaId(schemas[id]);
|
|
74
84
|
} catch (e) {
|
|
75
85
|
throw new Error("Couldn't transform the zod schema into an OpenAPI schema");
|
|
76
86
|
}
|
|
@@ -82,6 +92,7 @@ var z__namespace = /*#__PURE__*/_interopNamespace(z);
|
|
|
82
92
|
* @returns The constructed path string for the specified component schema.
|
|
83
93
|
*/ const toComponentsPath = (id)=>`#/components/schemas/${id}`;
|
|
84
94
|
|
|
95
|
+
exports.stripJsonSchemaId = stripJsonSchemaId;
|
|
85
96
|
exports.toComponentsPath = toComponentsPath;
|
|
86
97
|
exports.zodToOpenAPI = zodToOpenAPI;
|
|
87
98
|
//# sourceMappingURL=zod.js.map
|
package/dist/utils/zod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.js","sources":["../../src/utils/zod.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport * as z from 'zod/v4';\n\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\n/**\n * Converts a Zod schema to an OpenAPI Schema Object.\n *\n * @description\n * Takes a Zod schema and converts it into an OpenAPI Schema Object (v3.1).\n * It uses a local registry to handle the conversion process and generates the appropriate\n * OpenAPI components.\n *\n * @param zodSchema - The Zod schema to convert to OpenAPI format. Can be any valid Zod schema.\n *\n * @returns An OpenAPI Schema Object representing the input Zod schema structure.\n * If the conversion cannot be completed, returns undefined.\n *\n * @example\n * ```typescript\n * import * as z from 'zod/v4';\n *\n * // Create a Zod schema\n * const userSchema = z.object({\n * id: z.number(),\n * name: z.string(),\n * email: z.string().email()\n * });\n *\n * // Convert to OpenAPI schema\n * const openAPISchema = zodToOpenAPI(userSchema);\n * ```\n */\
|
|
1
|
+
{"version":3,"file":"zod.js","sources":["../../src/utils/zod.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport * as z from 'zod/v4';\n\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\n/**\n * Zod ≥3.25.76 embeds `$id` in `toJSONSchema` output (set after `override`).\n * Strip it so OpenAPI documents stay stable — inline schemas use random UUIDs\n * as registry ids — and match the pre-3.25.76 shape.\n */\nexport const stripJsonSchemaId = <T extends object>(schema: T): T => {\n if ('$id' in schema) {\n delete (schema as { $id?: string }).$id;\n }\n return schema;\n};\n\n/**\n * Converts a Zod schema to an OpenAPI Schema Object.\n *\n * @description\n * Takes a Zod schema and converts it into an OpenAPI Schema Object (v3.1).\n * It uses a local registry to handle the conversion process and generates the appropriate\n * OpenAPI components.\n *\n * @param zodSchema - The Zod schema to convert to OpenAPI format. Can be any valid Zod schema.\n *\n * @returns An OpenAPI Schema Object representing the input Zod schema structure.\n * If the conversion cannot be completed, returns undefined.\n *\n * @example\n * ```typescript\n * import * as z from 'zod/v4';\n *\n * // Create a Zod schema\n * const userSchema = z.object({\n * id: z.number(),\n * name: z.string(),\n * email: z.string().email()\n * });\n *\n * // Convert to OpenAPI schema\n * const openAPISchema = zodToOpenAPI(userSchema);\n * ```\n */\nexport const zodToOpenAPI = (\n zodSchema: z.ZodType\n): OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject => {\n try {\n const id = randomUUID();\n const registry = z.registry<{ id: string }>();\n\n // Add the schema to the local registry with a custom, unique ID\n registry.add(zodSchema, { id });\n\n // Copy the global registry definitions into the local registry to make sure references are resolved\n // This prevent \"__shared\" definitions from being created\n for (const [key, value] of z.globalRegistry._idmap) {\n registry.add(value, { id: key });\n }\n\n // Generate the schemas and only return the one we want, transform the URI path to be OpenAPI compliant\n const { schemas } = z.toJSONSchema(registry, { uri: toComponentsPath });\n\n // TODO: make sure it's compliant\n return stripJsonSchemaId(schemas[id] as OpenAPIV3_1.SchemaObject);\n } catch (e) {\n throw new Error(\"Couldn't transform the zod schema into an OpenAPI schema\");\n }\n};\n\n/**\n * Generates a path string for referencing a component schema by its identifier.\n *\n * @param id - The identifier of the component schema.\n * @returns The constructed path string for the specified component schema.\n */\nexport const toComponentsPath = (id: string) => `#/components/schemas/${id}`;\n"],"names":["stripJsonSchemaId","schema","$id","zodToOpenAPI","zodSchema","id","randomUUID","registry","z","add","key","value","globalRegistry","_idmap","schemas","toJSONSchema","uri","toComponentsPath","e","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;;;IAKO,MAAMA,iBAAAA,GAAoB,CAAmBC,MAAAA,GAAAA;AAClD,IAAA,IAAI,SAASA,MAAAA,EAAQ;QACnB,OAAQA,OAA4BC,GAAG;AACzC,IAAA;IACA,OAAOD,MAAAA;AACT;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4BO,MAAME,YAAAA,GAAe,CAC1BC,SAAAA,GAAAA;IAEA,IAAI;AACF,QAAA,MAAMC,EAAAA,GAAKC,sBAAAA,EAAAA;QACX,MAAMC,QAAAA,GAAWC,aAAED,QAAQ,EAAA;;QAG3BA,QAAAA,CAASE,GAAG,CAACL,SAAAA,EAAW;AAAEC,YAAAA;AAAG,SAAA,CAAA;;;QAI7B,KAAK,MAAM,CAACK,GAAAA,EAAKC,KAAAA,CAAM,IAAIH,YAAAA,CAAEI,cAAc,CAACC,MAAM,CAAE;YAClDN,QAAAA,CAASE,GAAG,CAACE,KAAAA,EAAO;gBAAEN,EAAAA,EAAIK;AAAI,aAAA,CAAA;AAChC,QAAA;;AAGA,QAAA,MAAM,EAAEI,OAAO,EAAE,GAAGN,YAAAA,CAAEO,YAAY,CAACR,QAAAA,EAAU;YAAES,GAAAA,EAAKC;AAAiB,SAAA,CAAA;;QAGrE,OAAOjB,iBAAAA,CAAkBc,OAAO,CAACT,EAAAA,CAAG,CAAA;AACtC,IAAA,CAAA,CAAE,OAAOa,CAAAA,EAAG;AACV,QAAA,MAAM,IAAIC,KAAAA,CAAM,0DAAA,CAAA;AAClB,IAAA;AACF;AAEA;;;;;UAMaF,gBAAAA,GAAmB,CAACZ,KAAe,CAAC,qBAAqB,EAAEA,EAAAA,CAAAA;;;;;;"}
|
package/dist/utils/zod.mjs
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import * as z from 'zod/v4';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Zod ≥3.25.76 embeds `$id` in `toJSONSchema` output (set after `override`).
|
|
6
|
+
* Strip it so OpenAPI documents stay stable — inline schemas use random UUIDs
|
|
7
|
+
* as registry ids — and match the pre-3.25.76 shape.
|
|
8
|
+
*/ const stripJsonSchemaId = (schema)=>{
|
|
9
|
+
if ('$id' in schema) {
|
|
10
|
+
delete schema.$id;
|
|
11
|
+
}
|
|
12
|
+
return schema;
|
|
13
|
+
};
|
|
4
14
|
/**
|
|
5
15
|
* Converts a Zod schema to an OpenAPI Schema Object.
|
|
6
16
|
*
|
|
@@ -48,7 +58,7 @@ import * as z from 'zod/v4';
|
|
|
48
58
|
uri: toComponentsPath
|
|
49
59
|
});
|
|
50
60
|
// TODO: make sure it's compliant
|
|
51
|
-
return schemas[id];
|
|
61
|
+
return stripJsonSchemaId(schemas[id]);
|
|
52
62
|
} catch (e) {
|
|
53
63
|
throw new Error("Couldn't transform the zod schema into an OpenAPI schema");
|
|
54
64
|
}
|
|
@@ -60,5 +70,5 @@ import * as z from 'zod/v4';
|
|
|
60
70
|
* @returns The constructed path string for the specified component schema.
|
|
61
71
|
*/ const toComponentsPath = (id)=>`#/components/schemas/${id}`;
|
|
62
72
|
|
|
63
|
-
export { toComponentsPath, zodToOpenAPI };
|
|
73
|
+
export { stripJsonSchemaId, toComponentsPath, zodToOpenAPI };
|
|
64
74
|
//# sourceMappingURL=zod.mjs.map
|
package/dist/utils/zod.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.mjs","sources":["../../src/utils/zod.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport * as z from 'zod/v4';\n\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\n/**\n * Converts a Zod schema to an OpenAPI Schema Object.\n *\n * @description\n * Takes a Zod schema and converts it into an OpenAPI Schema Object (v3.1).\n * It uses a local registry to handle the conversion process and generates the appropriate\n * OpenAPI components.\n *\n * @param zodSchema - The Zod schema to convert to OpenAPI format. Can be any valid Zod schema.\n *\n * @returns An OpenAPI Schema Object representing the input Zod schema structure.\n * If the conversion cannot be completed, returns undefined.\n *\n * @example\n * ```typescript\n * import * as z from 'zod/v4';\n *\n * // Create a Zod schema\n * const userSchema = z.object({\n * id: z.number(),\n * name: z.string(),\n * email: z.string().email()\n * });\n *\n * // Convert to OpenAPI schema\n * const openAPISchema = zodToOpenAPI(userSchema);\n * ```\n */\
|
|
1
|
+
{"version":3,"file":"zod.mjs","sources":["../../src/utils/zod.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport * as z from 'zod/v4';\n\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\n/**\n * Zod ≥3.25.76 embeds `$id` in `toJSONSchema` output (set after `override`).\n * Strip it so OpenAPI documents stay stable — inline schemas use random UUIDs\n * as registry ids — and match the pre-3.25.76 shape.\n */\nexport const stripJsonSchemaId = <T extends object>(schema: T): T => {\n if ('$id' in schema) {\n delete (schema as { $id?: string }).$id;\n }\n return schema;\n};\n\n/**\n * Converts a Zod schema to an OpenAPI Schema Object.\n *\n * @description\n * Takes a Zod schema and converts it into an OpenAPI Schema Object (v3.1).\n * It uses a local registry to handle the conversion process and generates the appropriate\n * OpenAPI components.\n *\n * @param zodSchema - The Zod schema to convert to OpenAPI format. Can be any valid Zod schema.\n *\n * @returns An OpenAPI Schema Object representing the input Zod schema structure.\n * If the conversion cannot be completed, returns undefined.\n *\n * @example\n * ```typescript\n * import * as z from 'zod/v4';\n *\n * // Create a Zod schema\n * const userSchema = z.object({\n * id: z.number(),\n * name: z.string(),\n * email: z.string().email()\n * });\n *\n * // Convert to OpenAPI schema\n * const openAPISchema = zodToOpenAPI(userSchema);\n * ```\n */\nexport const zodToOpenAPI = (\n zodSchema: z.ZodType\n): OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject => {\n try {\n const id = randomUUID();\n const registry = z.registry<{ id: string }>();\n\n // Add the schema to the local registry with a custom, unique ID\n registry.add(zodSchema, { id });\n\n // Copy the global registry definitions into the local registry to make sure references are resolved\n // This prevent \"__shared\" definitions from being created\n for (const [key, value] of z.globalRegistry._idmap) {\n registry.add(value, { id: key });\n }\n\n // Generate the schemas and only return the one we want, transform the URI path to be OpenAPI compliant\n const { schemas } = z.toJSONSchema(registry, { uri: toComponentsPath });\n\n // TODO: make sure it's compliant\n return stripJsonSchemaId(schemas[id] as OpenAPIV3_1.SchemaObject);\n } catch (e) {\n throw new Error(\"Couldn't transform the zod schema into an OpenAPI schema\");\n }\n};\n\n/**\n * Generates a path string for referencing a component schema by its identifier.\n *\n * @param id - The identifier of the component schema.\n * @returns The constructed path string for the specified component schema.\n */\nexport const toComponentsPath = (id: string) => `#/components/schemas/${id}`;\n"],"names":["stripJsonSchemaId","schema","$id","zodToOpenAPI","zodSchema","id","randomUUID","registry","z","add","key","value","globalRegistry","_idmap","schemas","toJSONSchema","uri","toComponentsPath","e","Error"],"mappings":";;;AAKA;;;;IAKO,MAAMA,iBAAAA,GAAoB,CAAmBC,MAAAA,GAAAA;AAClD,IAAA,IAAI,SAASA,MAAAA,EAAQ;QACnB,OAAQA,OAA4BC,GAAG;AACzC,IAAA;IACA,OAAOD,MAAAA;AACT;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4BO,MAAME,YAAAA,GAAe,CAC1BC,SAAAA,GAAAA;IAEA,IAAI;AACF,QAAA,MAAMC,EAAAA,GAAKC,UAAAA,EAAAA;QACX,MAAMC,QAAAA,GAAWC,EAAED,QAAQ,EAAA;;QAG3BA,QAAAA,CAASE,GAAG,CAACL,SAAAA,EAAW;AAAEC,YAAAA;AAAG,SAAA,CAAA;;;QAI7B,KAAK,MAAM,CAACK,GAAAA,EAAKC,KAAAA,CAAM,IAAIH,CAAAA,CAAEI,cAAc,CAACC,MAAM,CAAE;YAClDN,QAAAA,CAASE,GAAG,CAACE,KAAAA,EAAO;gBAAEN,EAAAA,EAAIK;AAAI,aAAA,CAAA;AAChC,QAAA;;AAGA,QAAA,MAAM,EAAEI,OAAO,EAAE,GAAGN,CAAAA,CAAEO,YAAY,CAACR,QAAAA,EAAU;YAAES,GAAAA,EAAKC;AAAiB,SAAA,CAAA;;QAGrE,OAAOjB,iBAAAA,CAAkBc,OAAO,CAACT,EAAAA,CAAG,CAAA;AACtC,IAAA,CAAA,CAAE,OAAOa,CAAAA,EAAG;AACV,QAAA,MAAM,IAAIC,KAAAA,CAAM,0DAAA,CAAA;AAClB,IAAA;AACF;AAEA;;;;;UAMaF,gBAAAA,GAAmB,CAACZ,KAAe,CAAC,qBAAqB,EAAEA,EAAAA,CAAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/openapi",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.51.0",
|
|
4
4
|
"description": "A tool set to help generate and validate API documentation for Strapi projects",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -47,8 +47,9 @@
|
|
|
47
47
|
"build:types": "run -T tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
48
48
|
"watch": "run -T rollup -c -w",
|
|
49
49
|
"clean": "run -T rimraf ./dist",
|
|
50
|
-
"lint": "run -T eslint .",
|
|
50
|
+
"lint": "run -T eslint . --max-warnings=0",
|
|
51
51
|
"prepublishOnly": "yarn clean && yarn build",
|
|
52
|
+
"test:ts": "run -T tsc -p tsconfig.json",
|
|
52
53
|
"test:unit": "run -T jest",
|
|
53
54
|
"test:unit:watch": "run -T jest --watch"
|
|
54
55
|
},
|
|
@@ -59,10 +60,13 @@
|
|
|
59
60
|
"dependencies": {
|
|
60
61
|
"debug": "4.3.4",
|
|
61
62
|
"openapi-types": "12.1.3",
|
|
62
|
-
"zod": "3.25.
|
|
63
|
+
"zod": "3.25.76"
|
|
63
64
|
},
|
|
64
65
|
"devDependencies": {
|
|
65
|
-
"@strapi/types": "5.
|
|
66
|
-
"@types/debug": "^4"
|
|
66
|
+
"@strapi/types": "5.51.0",
|
|
67
|
+
"@types/debug": "^4",
|
|
68
|
+
"@types/jest": "29.5.2",
|
|
69
|
+
"@types/node": "20.19.41",
|
|
70
|
+
"jest": "29.6.0"
|
|
67
71
|
}
|
|
68
72
|
}
|