@standard-community/standard-openapi 0.2.8 → 0.2.10
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/{default-DyJyARWC.cjs → default-DNjsfw3o.cjs} +2 -2
- package/dist/{index-CzVFvajF.cjs → index-BPRfQ1mx.cjs} +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{utils-D4f8cMSa.d.ts → utils-6SPsNbjx.d.cts} +1 -1
- package/dist/utils-6SPsNbjx.d.ts +10 -0
- package/dist/{valibot-sgPHXFKJ.cjs → valibot-CNm53x33.cjs} +2 -2
- package/dist/vendors/convert.cjs +16 -7
- package/dist/vendors/convert.d.cts +1 -1
- package/dist/vendors/convert.d.ts +1 -1
- package/dist/vendors/convert.js +16 -7
- package/dist/{zod-DrFzROei.cjs → zod-DZIcm8dB.cjs} +2 -2
- package/package.json +7 -5
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var standardJson = require('@standard-community/standard-json');
|
|
4
|
-
var
|
|
4
|
+
var vendors_convert = require('./vendors/convert.cjs');
|
|
5
5
|
|
|
6
6
|
function getToOpenAPISchemaFn() {
|
|
7
|
-
return async (schema, context) =>
|
|
7
|
+
return async (schema, context) => vendors_convert.convertToOpenAPISchema(
|
|
8
8
|
await standardJson.toJsonSchema(schema, context.options),
|
|
9
9
|
context
|
|
10
10
|
);
|
|
@@ -11,13 +11,13 @@ const getToOpenAPISchemaFn = async (vendor) => {
|
|
|
11
11
|
let vendorFn;
|
|
12
12
|
switch (vendor) {
|
|
13
13
|
case "valibot":
|
|
14
|
-
vendorFn = (await Promise.resolve().then(function () { return require('./valibot-
|
|
14
|
+
vendorFn = (await Promise.resolve().then(function () { return require('./valibot-CNm53x33.cjs'); })).default();
|
|
15
15
|
break;
|
|
16
16
|
case "zod":
|
|
17
|
-
vendorFn = (await Promise.resolve().then(function () { return require('./zod-
|
|
17
|
+
vendorFn = (await Promise.resolve().then(function () { return require('./zod-DZIcm8dB.cjs'); })).default();
|
|
18
18
|
break;
|
|
19
19
|
default:
|
|
20
|
-
vendorFn = (await Promise.resolve().then(function () { return require('./default-
|
|
20
|
+
vendorFn = (await Promise.resolve().then(function () { return require('./default-DNjsfw3o.cjs'); })).default();
|
|
21
21
|
}
|
|
22
22
|
openapiVendorMap.set(vendor, vendorFn);
|
|
23
23
|
return vendorFn;
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as openapi_types from 'openapi-types';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
-
import { T as
|
|
3
|
+
import { T as ToOpenAPISchemaFn, a as ToOpenAPISchemaContext } from './utils-6SPsNbjx.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Converts a Standard Schema to a OpenAPI schema.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as openapi_types from 'openapi-types';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
-
import { T as
|
|
3
|
+
import { T as ToOpenAPISchemaFn, a as ToOpenAPISchemaContext } from './utils-6SPsNbjx.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Converts a Standard Schema to a OpenAPI schema.
|
|
@@ -7,4 +7,4 @@ type ToOpenAPISchemaContext = {
|
|
|
7
7
|
};
|
|
8
8
|
type ToOpenAPISchemaFn = (schema: StandardSchemaV1, context: ToOpenAPISchemaContext) => OpenAPIV3_1.SchemaObject | Promise<OpenAPIV3_1.SchemaObject>;
|
|
9
9
|
|
|
10
|
-
export type {
|
|
10
|
+
export type { ToOpenAPISchemaFn as T, ToOpenAPISchemaContext as a };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import { OpenAPIV3_1 } from 'openapi-types';
|
|
3
|
+
|
|
4
|
+
type ToOpenAPISchemaContext = {
|
|
5
|
+
components: OpenAPIV3_1.ComponentsObject;
|
|
6
|
+
options?: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
type ToOpenAPISchemaFn = (schema: StandardSchemaV1, context: ToOpenAPISchemaContext) => OpenAPIV3_1.SchemaObject | Promise<OpenAPIV3_1.SchemaObject>;
|
|
9
|
+
|
|
10
|
+
export type { ToOpenAPISchemaFn as T, ToOpenAPISchemaContext as a };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var standardJson = require('@standard-community/standard-json');
|
|
4
|
-
var
|
|
4
|
+
var vendors_convert = require('./vendors/convert.cjs');
|
|
5
5
|
|
|
6
6
|
function getToOpenAPISchemaFn() {
|
|
7
7
|
return async (schema, context) => {
|
|
@@ -9,7 +9,7 @@ function getToOpenAPISchemaFn() {
|
|
|
9
9
|
errorMode: "ignore",
|
|
10
10
|
// @ts-expect-error
|
|
11
11
|
overrideAction: ({ valibotAction, jsonSchema }) => {
|
|
12
|
-
const _jsonSchema =
|
|
12
|
+
const _jsonSchema = vendors_convert.convertToOpenAPISchema(jsonSchema, context);
|
|
13
13
|
if (valibotAction.kind === "metadata" && valibotAction.type === "metadata" && !("$ref" in _jsonSchema)) {
|
|
14
14
|
const metadata = valibotAction.metadata;
|
|
15
15
|
if (metadata.example !== void 0) {
|
package/dist/vendors/convert.cjs
CHANGED
|
@@ -65,6 +65,15 @@ function convertToOpenAPISchema(jsonSchema, context) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
|
+
if (_jsonSchema.$defs || _jsonSchema.definitions) {
|
|
69
|
+
context.components.schemas = {
|
|
70
|
+
..._jsonSchema.definitions,
|
|
71
|
+
..._jsonSchema.$defs,
|
|
72
|
+
...context.components.schemas
|
|
73
|
+
};
|
|
74
|
+
delete _jsonSchema.$defs;
|
|
75
|
+
delete _jsonSchema.definitions;
|
|
76
|
+
}
|
|
68
77
|
if (_jsonSchema.ref || _jsonSchema.$id) {
|
|
69
78
|
const { ref, $id, ...component } = _jsonSchema;
|
|
70
79
|
const id = ref || $id;
|
|
@@ -76,14 +85,14 @@ function convertToOpenAPISchema(jsonSchema, context) {
|
|
|
76
85
|
$ref: `#/components/schemas/${id}`
|
|
77
86
|
};
|
|
78
87
|
} else if (_jsonSchema.$ref) {
|
|
79
|
-
const { $ref,
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
...
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
const { $ref, ...rest } = _jsonSchema;
|
|
89
|
+
const lowerRef = $ref.toLowerCase();
|
|
90
|
+
if (lowerRef.startsWith("http://") || lowerRef.startsWith("https://") || $ref.startsWith("//")) {
|
|
91
|
+
return { ...rest, $ref };
|
|
92
|
+
}
|
|
93
|
+
const ref = $ref.split("/").pop();
|
|
85
94
|
return {
|
|
86
|
-
$ref: `#/components/schemas/${
|
|
95
|
+
$ref: `#/components/schemas/${ref}`
|
|
87
96
|
};
|
|
88
97
|
}
|
|
89
98
|
return _jsonSchema;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
-
import {
|
|
2
|
+
import { ToOpenAPISchemaContext } from '../index.cjs';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
|
|
5
5
|
// ==================================================================================================
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
-
import {
|
|
2
|
+
import { ToOpenAPISchemaContext } from '../index.js';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
|
|
5
5
|
// ==================================================================================================
|
package/dist/vendors/convert.js
CHANGED
|
@@ -63,6 +63,15 @@ function convertToOpenAPISchema(jsonSchema, context) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
+
if (_jsonSchema.$defs || _jsonSchema.definitions) {
|
|
67
|
+
context.components.schemas = {
|
|
68
|
+
..._jsonSchema.definitions,
|
|
69
|
+
..._jsonSchema.$defs,
|
|
70
|
+
...context.components.schemas
|
|
71
|
+
};
|
|
72
|
+
delete _jsonSchema.$defs;
|
|
73
|
+
delete _jsonSchema.definitions;
|
|
74
|
+
}
|
|
66
75
|
if (_jsonSchema.ref || _jsonSchema.$id) {
|
|
67
76
|
const { ref, $id, ...component } = _jsonSchema;
|
|
68
77
|
const id = ref || $id;
|
|
@@ -74,14 +83,14 @@ function convertToOpenAPISchema(jsonSchema, context) {
|
|
|
74
83
|
$ref: `#/components/schemas/${id}`
|
|
75
84
|
};
|
|
76
85
|
} else if (_jsonSchema.$ref) {
|
|
77
|
-
const { $ref,
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
...
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
const { $ref, ...rest } = _jsonSchema;
|
|
87
|
+
const lowerRef = $ref.toLowerCase();
|
|
88
|
+
if (lowerRef.startsWith("http://") || lowerRef.startsWith("https://") || $ref.startsWith("//")) {
|
|
89
|
+
return { ...rest, $ref };
|
|
90
|
+
}
|
|
91
|
+
const ref = $ref.split("/").pop();
|
|
83
92
|
return {
|
|
84
|
-
$ref: `#/components/schemas/${
|
|
93
|
+
$ref: `#/components/schemas/${ref}`
|
|
85
94
|
};
|
|
86
95
|
}
|
|
87
96
|
return _jsonSchema;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _default = require('./default-
|
|
4
|
-
var index = require('./index-
|
|
3
|
+
var _default = require('./default-DNjsfw3o.cjs');
|
|
4
|
+
var index = require('./index-BPRfQ1mx.cjs');
|
|
5
5
|
require('@standard-community/standard-json');
|
|
6
6
|
require('./vendors/convert.cjs');
|
|
7
7
|
|
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.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"@standard-community/standard-json": "^0.3.5",
|
|
55
55
|
"@standard-schema/spec": "^1.0.0",
|
|
56
56
|
"arktype": "^2.1.20",
|
|
57
|
-
"effect": "^3.
|
|
57
|
+
"effect": "^3.20.0",
|
|
58
58
|
"openapi-types": "^12.1.3",
|
|
59
59
|
"sury": "^10.0.0",
|
|
60
60
|
"typebox": "^1.0.0",
|
|
61
|
-
"valibot": "^1.
|
|
61
|
+
"valibot": "^1.4.2",
|
|
62
62
|
"zod": "^3.25.0 || ^4.0.0",
|
|
63
63
|
"zod-openapi": "^4"
|
|
64
64
|
},
|
|
@@ -90,9 +90,11 @@
|
|
|
90
90
|
"@types/json-schema": "^7.0.15",
|
|
91
91
|
"@types/node": "^24.3.1",
|
|
92
92
|
"@valibot/to-json-schema": "^1.3.0",
|
|
93
|
-
"pkgroll": "^2.
|
|
93
|
+
"pkgroll": "^2.28.1",
|
|
94
|
+
"typebox": "1.0.17",
|
|
94
95
|
"typescript": "^5.8.3",
|
|
95
|
-
"vitest": "^3.2.
|
|
96
|
+
"vitest": "^3.2.6",
|
|
97
|
+
"zod": "^3.25.67",
|
|
96
98
|
"zod-to-json-schema": "^3.24.6"
|
|
97
99
|
},
|
|
98
100
|
"scripts": {
|