@standard-community/standard-openapi 0.2.4 → 0.2.6

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.cjs CHANGED
@@ -19,6 +19,7 @@ const getToOpenAPISchemaFn = async (vendor) => {
19
19
  break;
20
20
  case "arktype":
21
21
  case "effect":
22
+ case "typebox":
22
23
  vendorFn = (await Promise.resolve().then(function () { return require('./default-DyJyARWC.cjs'); })).default();
23
24
  break;
24
25
  default:
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ const getToOpenAPISchemaFn = async (vendor) => {
15
15
  break;
16
16
  case "arktype":
17
17
  case "effect":
18
+ case "typebox":
18
19
  vendorFn = (await import('./default-u_dwuiYb.js')).default();
19
20
  break;
20
21
  default:
@@ -65,14 +65,25 @@ function convertToOpenAPISchema(jsonSchema, context) {
65
65
  }
66
66
  }
67
67
  });
68
- if (_jsonSchema.ref) {
69
- const { ref, ...component } = _jsonSchema;
68
+ if (_jsonSchema.ref || _jsonSchema.$id) {
69
+ const { ref, $id, ...component } = _jsonSchema;
70
+ const id = ref || $id;
70
71
  context.components.schemas = {
71
72
  ...context.components.schemas,
72
- [ref]: component
73
+ [id]: component
73
74
  };
74
75
  return {
75
- $ref: `#/components/schemas/${ref}`
76
+ $ref: `#/components/schemas/${id}`
77
+ };
78
+ } else if (_jsonSchema.$ref) {
79
+ const { $ref, $defs } = _jsonSchema;
80
+ const EFFECT_DEFS_PREFIX = "#/$defs/";
81
+ context.components.schemas = {
82
+ ...context.components.schemas,
83
+ ...$defs
84
+ };
85
+ return {
86
+ $ref: `#/components/schemas/${$ref.slice(EFFECT_DEFS_PREFIX.length)}`
76
87
  };
77
88
  }
78
89
  return _jsonSchema;
@@ -63,14 +63,25 @@ function convertToOpenAPISchema(jsonSchema, context) {
63
63
  }
64
64
  }
65
65
  });
66
- if (_jsonSchema.ref) {
67
- const { ref, ...component } = _jsonSchema;
66
+ if (_jsonSchema.ref || _jsonSchema.$id) {
67
+ const { ref, $id, ...component } = _jsonSchema;
68
+ const id = ref || $id;
68
69
  context.components.schemas = {
69
70
  ...context.components.schemas,
70
- [ref]: component
71
+ [id]: component
71
72
  };
72
73
  return {
73
- $ref: `#/components/schemas/${ref}`
74
+ $ref: `#/components/schemas/${id}`
75
+ };
76
+ } else if (_jsonSchema.$ref) {
77
+ const { $ref, $defs } = _jsonSchema;
78
+ const EFFECT_DEFS_PREFIX = "#/$defs/";
79
+ context.components.schemas = {
80
+ ...context.components.schemas,
81
+ ...$defs
82
+ };
83
+ return {
84
+ $ref: `#/components/schemas/${$ref.slice(EFFECT_DEFS_PREFIX.length)}`
74
85
  };
75
86
  }
76
87
  return _jsonSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@standard-community/standard-openapi",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.cjs",
@@ -71,10 +71,12 @@
71
71
  }
72
72
  },
73
73
  "peerDependencies": {
74
- "@standard-community/standard-json": "^0.3.1",
74
+ "@standard-community/standard-json": "^0.3.4",
75
75
  "@standard-schema/spec": "^1.0.0",
76
76
  "arktype": "^2.1.20",
77
+ "effect": "^3.17.14",
77
78
  "openapi-types": "^12.1.3",
79
+ "typebox": "^1.0.0",
78
80
  "valibot": "^1.1.0",
79
81
  "zod": "^3.25.0 || ^4.0.0",
80
82
  "zod-openapi": "^4"
@@ -83,6 +85,12 @@
83
85
  "arktype": {
84
86
  "optional": true
85
87
  },
88
+ "effect": {
89
+ "optional": true
90
+ },
91
+ "typebox": {
92
+ "optional": true
93
+ },
86
94
  "valibot": {
87
95
  "optional": true
88
96
  },