@standard-community/standard-openapi 0.2.7 → 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.
@@ -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 utils = require('./utils-DibZ0_jm.cjs');
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
- const toOpenAPISchema = async (schema, context = {}) => {
35
- const fn = await getToOpenAPISchemaFn(schema["~standard"].vendor);
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
- import { o as openapiVendorMap, e as errorMessageWrapper } from './utils-Dhi4Aks8.js';
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,5 +1,5 @@
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) => {
@@ -1,7 +1,7 @@
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) => {
@@ -39,4 +39,4 @@ function getToOpenAPISchemaFn() {
39
39
  };
40
40
  }
41
41
 
42
- module.exports = getToOpenAPISchemaFn;
42
+ exports.default = getToOpenAPISchemaFn;
@@ -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(
@@ -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 '../default-u_dwuiYb.js';
2
- import { e as errorMessageWrapper } from '../utils-Dhi4Aks8.js';
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('../default-DyJyARWC.cjs');
4
- var utils = require('../utils-DibZ0_jm.cjs');
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
- utils.errorMessageWrapper(`Missing dependencies "zod-openapi v4".`)
32
+ index.errorMessageWrapper(`Missing dependencies "zod-openapi v4".`)
33
33
  );
34
34
  }
35
35
  };
36
36
  }
37
37
 
38
- module.exports = getToOpenAPISchemaFn;
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.7",
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.4",
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
  },
@@ -1,4 +0,0 @@
1
- const errorMessageWrapper = (message) => `standard-openapi: ${message}`;
2
- const openapiVendorMap = /* @__PURE__ */ new Map();
3
-
4
- export { errorMessageWrapper as e, openapiVendorMap as o };
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- const errorMessageWrapper = (message) => `standard-openapi: ${message}`;
4
- const openapiVendorMap = /* @__PURE__ */ new Map();
5
-
6
- exports.errorMessageWrapper = errorMessageWrapper;
7
- exports.openapiVendorMap = openapiVendorMap;
@@ -1,7 +0,0 @@
1
- import { a as ToOpenAPISchemaFn } from '../utils-D4f8cMSa.js';
2
- import '@standard-schema/spec';
3
- import 'openapi-types';
4
-
5
- declare function getToOpenAPISchemaFn(): ToOpenAPISchemaFn;
6
-
7
- export { getToOpenAPISchemaFn as default };
@@ -1,7 +0,0 @@
1
- import { a as ToOpenAPISchemaFn } from '../utils-D4f8cMSa.js';
2
- import '@standard-schema/spec';
3
- import 'openapi-types';
4
-
5
- declare function getToOpenAPISchemaFn(): ToOpenAPISchemaFn;
6
-
7
- export { getToOpenAPISchemaFn as default };
@@ -1,7 +0,0 @@
1
- import { a as ToOpenAPISchemaFn } from '../utils-D4f8cMSa.js';
2
- import '@standard-schema/spec';
3
- import 'openapi-types';
4
-
5
- declare function getToOpenAPISchemaFn(): ToOpenAPISchemaFn;
6
-
7
- export { getToOpenAPISchemaFn as default };
@@ -1,7 +0,0 @@
1
- import { a as ToOpenAPISchemaFn } from '../utils-D4f8cMSa.js';
2
- import '@standard-schema/spec';
3
- import 'openapi-types';
4
-
5
- declare function getToOpenAPISchemaFn(): ToOpenAPISchemaFn;
6
-
7
- export { getToOpenAPISchemaFn as default };