@standard-community/standard-openapi 0.2.6 → 0.2.8
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/index-CzVFvajF.cjs +41 -0
- package/dist/index-DZEfthgZ.js +37 -0
- package/dist/index.cjs +3 -43
- package/dist/index.js +1 -43
- package/dist/{vendors/valibot.js → valibot-D_HTw1Gn.js} +2 -1
- package/dist/{vendors/valibot.cjs → valibot-sgPHXFKJ.cjs} +3 -2
- package/dist/vendors/convert.cjs +1 -1
- package/dist/vendors/convert.js +1 -1
- package/dist/{vendors/zod.js → zod-DSgpEGAE.js} +3 -3
- package/dist/{vendors/zod.cjs → zod-DrFzROei.cjs} +5 -5
- package/package.json +6 -22
- package/dist/utils-Dhi4Aks8.js +0 -4
- package/dist/utils-DibZ0_jm.cjs +0 -7
- package/dist/vendors/valibot.d.cts +0 -7
- package/dist/vendors/valibot.d.ts +0 -7
- package/dist/vendors/zod.d.cts +0 -7
- package/dist/vendors/zod.d.ts +0 -7
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const errorMessageWrapper = (message) => `standard-openapi: ${message}`;
|
|
4
|
+
const openapiVendorMap = /* @__PURE__ */ new Map();
|
|
5
|
+
|
|
6
|
+
const getToOpenAPISchemaFn = async (vendor) => {
|
|
7
|
+
const cached = openapiVendorMap.get(vendor);
|
|
8
|
+
if (cached) {
|
|
9
|
+
return cached;
|
|
10
|
+
}
|
|
11
|
+
let vendorFn;
|
|
12
|
+
switch (vendor) {
|
|
13
|
+
case "valibot":
|
|
14
|
+
vendorFn = (await Promise.resolve().then(function () { return require('./valibot-sgPHXFKJ.cjs'); })).default();
|
|
15
|
+
break;
|
|
16
|
+
case "zod":
|
|
17
|
+
vendorFn = (await Promise.resolve().then(function () { return require('./zod-DrFzROei.cjs'); })).default();
|
|
18
|
+
break;
|
|
19
|
+
default:
|
|
20
|
+
vendorFn = (await Promise.resolve().then(function () { return require('./default-DyJyARWC.cjs'); })).default();
|
|
21
|
+
}
|
|
22
|
+
openapiVendorMap.set(vendor, vendorFn);
|
|
23
|
+
return vendorFn;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const toOpenAPISchema = async (schema, context = {}) => {
|
|
27
|
+
const fn = await getToOpenAPISchemaFn(schema["~standard"].vendor);
|
|
28
|
+
const { components = {}, options } = context;
|
|
29
|
+
const _schema = await fn(schema, { components, options });
|
|
30
|
+
return {
|
|
31
|
+
schema: _schema,
|
|
32
|
+
components: Object.keys(components).length > 0 ? components : void 0
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
function loadVendor(vendor, fn) {
|
|
36
|
+
openapiVendorMap.set(vendor, fn);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.errorMessageWrapper = errorMessageWrapper;
|
|
40
|
+
exports.loadVendor = loadVendor;
|
|
41
|
+
exports.toOpenAPISchema = toOpenAPISchema;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const errorMessageWrapper = (message) => `standard-openapi: ${message}`;
|
|
2
|
+
const openapiVendorMap = /* @__PURE__ */ new Map();
|
|
3
|
+
|
|
4
|
+
const getToOpenAPISchemaFn = async (vendor) => {
|
|
5
|
+
const cached = openapiVendorMap.get(vendor);
|
|
6
|
+
if (cached) {
|
|
7
|
+
return cached;
|
|
8
|
+
}
|
|
9
|
+
let vendorFn;
|
|
10
|
+
switch (vendor) {
|
|
11
|
+
case "valibot":
|
|
12
|
+
vendorFn = (await import('./valibot-D_HTw1Gn.js')).default();
|
|
13
|
+
break;
|
|
14
|
+
case "zod":
|
|
15
|
+
vendorFn = (await import('./zod-DSgpEGAE.js')).default();
|
|
16
|
+
break;
|
|
17
|
+
default:
|
|
18
|
+
vendorFn = (await import('./default-u_dwuiYb.js')).default();
|
|
19
|
+
}
|
|
20
|
+
openapiVendorMap.set(vendor, vendorFn);
|
|
21
|
+
return vendorFn;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const toOpenAPISchema = async (schema, context = {}) => {
|
|
25
|
+
const fn = await getToOpenAPISchemaFn(schema["~standard"].vendor);
|
|
26
|
+
const { components = {}, options } = context;
|
|
27
|
+
const _schema = await fn(schema, { components, options });
|
|
28
|
+
return {
|
|
29
|
+
schema: _schema,
|
|
30
|
+
components: Object.keys(components).length > 0 ? components : void 0
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
function loadVendor(vendor, fn) {
|
|
34
|
+
openapiVendorMap.set(vendor, fn);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { errorMessageWrapper as e, loadVendor as l, toOpenAPISchema as t };
|
package/dist/index.cjs
CHANGED
|
@@ -1,48 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var index = require('./index-CzVFvajF.cjs');
|
|
4
4
|
|
|
5
|
-
function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); }
|
|
6
5
|
|
|
7
|
-
const getToOpenAPISchemaFn = async (vendor) => {
|
|
8
|
-
const cached = utils.openapiVendorMap.get(vendor);
|
|
9
|
-
if (cached) {
|
|
10
|
-
return cached;
|
|
11
|
-
}
|
|
12
|
-
let vendorFn;
|
|
13
|
-
switch (vendor) {
|
|
14
|
-
case "valibot":
|
|
15
|
-
vendorFn = (await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./vendors/valibot.cjs')); })).default();
|
|
16
|
-
break;
|
|
17
|
-
case "zod":
|
|
18
|
-
vendorFn = (await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./vendors/zod.cjs')); })).default();
|
|
19
|
-
break;
|
|
20
|
-
case "arktype":
|
|
21
|
-
case "effect":
|
|
22
|
-
case "typebox":
|
|
23
|
-
vendorFn = (await Promise.resolve().then(function () { return require('./default-DyJyARWC.cjs'); })).default();
|
|
24
|
-
break;
|
|
25
|
-
default:
|
|
26
|
-
throw new Error(
|
|
27
|
-
utils.errorMessageWrapper(`Unsupported schema vendor "${vendor}".`)
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
utils.openapiVendorMap.set(vendor, vendorFn);
|
|
31
|
-
return vendorFn;
|
|
32
|
-
};
|
|
33
6
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const { components = {}, options } = context;
|
|
37
|
-
const _schema = await fn(schema, { components, options });
|
|
38
|
-
return {
|
|
39
|
-
schema: _schema,
|
|
40
|
-
components: Object.keys(components).length > 0 ? components : void 0
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
function loadVendor(vendor, fn) {
|
|
44
|
-
utils.openapiVendorMap.set(vendor, fn);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
exports.loadVendor = loadVendor;
|
|
48
|
-
exports.toOpenAPISchema = toOpenAPISchema;
|
|
7
|
+
exports.loadVendor = index.loadVendor;
|
|
8
|
+
exports.toOpenAPISchema = index.toOpenAPISchema;
|
package/dist/index.js
CHANGED
|
@@ -1,43 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const getToOpenAPISchemaFn = async (vendor) => {
|
|
4
|
-
const cached = openapiVendorMap.get(vendor);
|
|
5
|
-
if (cached) {
|
|
6
|
-
return cached;
|
|
7
|
-
}
|
|
8
|
-
let vendorFn;
|
|
9
|
-
switch (vendor) {
|
|
10
|
-
case "valibot":
|
|
11
|
-
vendorFn = (await import('./vendors/valibot.js')).default();
|
|
12
|
-
break;
|
|
13
|
-
case "zod":
|
|
14
|
-
vendorFn = (await import('./vendors/zod.js')).default();
|
|
15
|
-
break;
|
|
16
|
-
case "arktype":
|
|
17
|
-
case "effect":
|
|
18
|
-
case "typebox":
|
|
19
|
-
vendorFn = (await import('./default-u_dwuiYb.js')).default();
|
|
20
|
-
break;
|
|
21
|
-
default:
|
|
22
|
-
throw new Error(
|
|
23
|
-
errorMessageWrapper(`Unsupported schema vendor "${vendor}".`)
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
openapiVendorMap.set(vendor, vendorFn);
|
|
27
|
-
return vendorFn;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const toOpenAPISchema = async (schema, context = {}) => {
|
|
31
|
-
const fn = await getToOpenAPISchemaFn(schema["~standard"].vendor);
|
|
32
|
-
const { components = {}, options } = context;
|
|
33
|
-
const _schema = await fn(schema, { components, options });
|
|
34
|
-
return {
|
|
35
|
-
schema: _schema,
|
|
36
|
-
components: Object.keys(components).length > 0 ? components : void 0
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
function loadVendor(vendor, fn) {
|
|
40
|
-
openapiVendorMap.set(vendor, fn);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { loadVendor, toOpenAPISchema };
|
|
1
|
+
export { l as loadVendor, t as toOpenAPISchema } from './index-DZEfthgZ.js';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { toJsonSchema } from '@standard-community/standard-json';
|
|
2
|
-
import { convertToOpenAPISchema } from './convert.js';
|
|
2
|
+
import { convertToOpenAPISchema } from './vendors/convert.js';
|
|
3
3
|
|
|
4
4
|
function getToOpenAPISchemaFn() {
|
|
5
5
|
return async (schema, context) => {
|
|
6
6
|
const openapiSchema = await toJsonSchema(schema, {
|
|
7
|
+
errorMode: "ignore",
|
|
7
8
|
// @ts-expect-error
|
|
8
9
|
overrideAction: ({ valibotAction, jsonSchema }) => {
|
|
9
10
|
const _jsonSchema = convertToOpenAPISchema(jsonSchema, context);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var standardJson = require('@standard-community/standard-json');
|
|
4
|
-
var convert = require('./convert.cjs');
|
|
4
|
+
var convert = require('./vendors/convert.cjs');
|
|
5
5
|
|
|
6
6
|
function getToOpenAPISchemaFn() {
|
|
7
7
|
return async (schema, context) => {
|
|
8
8
|
const openapiSchema = await standardJson.toJsonSchema(schema, {
|
|
9
|
+
errorMode: "ignore",
|
|
9
10
|
// @ts-expect-error
|
|
10
11
|
overrideAction: ({ valibotAction, jsonSchema }) => {
|
|
11
12
|
const _jsonSchema = convert.convertToOpenAPISchema(jsonSchema, context);
|
|
@@ -38,4 +39,4 @@ function getToOpenAPISchemaFn() {
|
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
exports.default = getToOpenAPISchemaFn;
|
package/dist/vendors/convert.cjs
CHANGED
|
@@ -40,7 +40,7 @@ function convertToOpenAPISchema(jsonSchema, context) {
|
|
|
40
40
|
// "unevaluatedItems",
|
|
41
41
|
];
|
|
42
42
|
nestedSchemaKeys.forEach((key) => {
|
|
43
|
-
if (_jsonSchema[key]) {
|
|
43
|
+
if (_jsonSchema[key] && (typeof _jsonSchema[key] === "object" || Array.isArray(_jsonSchema[key]))) {
|
|
44
44
|
if (key === "properties" || key === "definitions" || key === "$defs" || key === "patternProperties") {
|
|
45
45
|
for (const subKey in _jsonSchema[key]) {
|
|
46
46
|
_jsonSchema[key][subKey] = convertToOpenAPISchema(
|
package/dist/vendors/convert.js
CHANGED
|
@@ -38,7 +38,7 @@ function convertToOpenAPISchema(jsonSchema, context) {
|
|
|
38
38
|
// "unevaluatedItems",
|
|
39
39
|
];
|
|
40
40
|
nestedSchemaKeys.forEach((key) => {
|
|
41
|
-
if (_jsonSchema[key]) {
|
|
41
|
+
if (_jsonSchema[key] && (typeof _jsonSchema[key] === "object" || Array.isArray(_jsonSchema[key]))) {
|
|
42
42
|
if (key === "properties" || key === "definitions" || key === "$defs" || key === "patternProperties") {
|
|
43
43
|
for (const subKey in _jsonSchema[key]) {
|
|
44
44
|
_jsonSchema[key][subKey] = convertToOpenAPISchema(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import getToOpenAPISchemaFn$1 from '
|
|
2
|
-
import { e as errorMessageWrapper } from '
|
|
1
|
+
import getToOpenAPISchemaFn$1 from './default-u_dwuiYb.js';
|
|
2
|
+
import { e as errorMessageWrapper } from './index-DZEfthgZ.js';
|
|
3
3
|
import '@standard-community/standard-json';
|
|
4
|
-
import './convert.js';
|
|
4
|
+
import './vendors/convert.js';
|
|
5
5
|
|
|
6
6
|
function getToOpenAPISchemaFn() {
|
|
7
7
|
return async (schema, context) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _default = require('
|
|
4
|
-
var
|
|
3
|
+
var _default = require('./default-DyJyARWC.cjs');
|
|
4
|
+
var index = require('./index-CzVFvajF.cjs');
|
|
5
5
|
require('@standard-community/standard-json');
|
|
6
|
-
require('./convert.cjs');
|
|
6
|
+
require('./vendors/convert.cjs');
|
|
7
7
|
|
|
8
8
|
function getToOpenAPISchemaFn() {
|
|
9
9
|
return async (schema, context) => {
|
|
@@ -29,10 +29,10 @@ function getToOpenAPISchemaFn() {
|
|
|
29
29
|
return _schema;
|
|
30
30
|
} catch {
|
|
31
31
|
throw new Error(
|
|
32
|
-
|
|
32
|
+
index.errorMessageWrapper(`Missing dependencies "zod-openapi v4".`)
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
exports.default = getToOpenAPISchemaFn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@standard-community/standard-openapi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -48,34 +48,15 @@
|
|
|
48
48
|
"types": "./dist/vendors/convert.d.cts",
|
|
49
49
|
"default": "./dist/vendors/convert.cjs"
|
|
50
50
|
}
|
|
51
|
-
},
|
|
52
|
-
"./valibot": {
|
|
53
|
-
"import": {
|
|
54
|
-
"types": "./dist/vendors/valibot.d.ts",
|
|
55
|
-
"default": "./dist/vendors/valibot.js"
|
|
56
|
-
},
|
|
57
|
-
"require": {
|
|
58
|
-
"types": "./dist/vendors/valibot.d.cts",
|
|
59
|
-
"default": "./dist/vendors/valibot.cjs"
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
"./zod": {
|
|
63
|
-
"import": {
|
|
64
|
-
"types": "./dist/vendors/zod.d.ts",
|
|
65
|
-
"default": "./dist/vendors/zod.js"
|
|
66
|
-
},
|
|
67
|
-
"require": {
|
|
68
|
-
"types": "./dist/vendors/zod.d.cts",
|
|
69
|
-
"default": "./dist/vendors/zod.cjs"
|
|
70
|
-
}
|
|
71
51
|
}
|
|
72
52
|
},
|
|
73
53
|
"peerDependencies": {
|
|
74
|
-
"@standard-community/standard-json": "^0.3.
|
|
54
|
+
"@standard-community/standard-json": "^0.3.5",
|
|
75
55
|
"@standard-schema/spec": "^1.0.0",
|
|
76
56
|
"arktype": "^2.1.20",
|
|
77
57
|
"effect": "^3.17.14",
|
|
78
58
|
"openapi-types": "^12.1.3",
|
|
59
|
+
"sury": "^10.0.0",
|
|
79
60
|
"typebox": "^1.0.0",
|
|
80
61
|
"valibot": "^1.1.0",
|
|
81
62
|
"zod": "^3.25.0 || ^4.0.0",
|
|
@@ -88,6 +69,9 @@
|
|
|
88
69
|
"effect": {
|
|
89
70
|
"optional": true
|
|
90
71
|
},
|
|
72
|
+
"sury": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
91
75
|
"typebox": {
|
|
92
76
|
"optional": true
|
|
93
77
|
},
|
package/dist/utils-Dhi4Aks8.js
DELETED
package/dist/utils-DibZ0_jm.cjs
DELETED
package/dist/vendors/zod.d.cts
DELETED
package/dist/vendors/zod.d.ts
DELETED