@kizunajs/openapi 2.0.0-beta.22 → 2.0.0-beta.24
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 +8 -15
- package/dist/index.mjs +9 -16
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -80,25 +80,17 @@ const buildDiscriminatorBlock = (propertyName, options) => {
|
|
|
80
80
|
} : { propertyName };
|
|
81
81
|
};
|
|
82
82
|
/**
|
|
83
|
-
* What the wire carries for a type JSON Schema has no keyword for, which
|
|
84
|
-
* `unrepresentable: 'any'` would otherwise leave as an empty schema.
|
|
85
|
-
*/
|
|
86
|
-
const JSON_ENCODING = {
|
|
87
|
-
date: {
|
|
88
|
-
type: "string",
|
|
89
|
-
format: "date-time"
|
|
90
|
-
},
|
|
91
|
-
bigint: { type: "string" }
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
83
|
* kizuna's metadata widens JSON Schema: `deprecated` may carry a message,
|
|
95
84
|
* `example` holds one value or several, and `brand` has no keyword. Emit
|
|
96
85
|
* `deprecated: true`, an `examples` array and `x-kizuna-brand`; the message
|
|
97
|
-
* stays in outputs with a place for it, like Swift's `@available`.
|
|
86
|
+
* stays in outputs with a place for it, like Swift's `@available`. `id` names
|
|
87
|
+
* the component, so it is dropped.
|
|
98
88
|
*/
|
|
99
89
|
const normalizeMeta = ({ zodSchema, jsonSchema }) => {
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
(0, kizunajs_generator.encodeForWire)({
|
|
91
|
+
zodSchema,
|
|
92
|
+
jsonSchema
|
|
93
|
+
});
|
|
102
94
|
if (typeof jsonSchema.deprecated === "string") jsonSchema.deprecated = true;
|
|
103
95
|
if ("example" in jsonSchema) {
|
|
104
96
|
const given = Array.isArray(jsonSchema.example) ? jsonSchema.example : [jsonSchema.example];
|
|
@@ -110,9 +102,10 @@ const normalizeMeta = ({ zodSchema, jsonSchema }) => {
|
|
|
110
102
|
jsonSchema["x-kizuna-brand"] = jsonSchema.brand;
|
|
111
103
|
delete jsonSchema.brand;
|
|
112
104
|
}
|
|
105
|
+
delete jsonSchema.id;
|
|
113
106
|
};
|
|
114
107
|
const toJsonSchema = (schema, io = "output") => {
|
|
115
|
-
const id = (0, kizunajs_generator.readMetaId)(schema);
|
|
108
|
+
const id = (0, kizunajs_generator.readModelSchema)(schema) === schema ? (0, kizunajs_generator.readMetaId)(schema) : void 0;
|
|
116
109
|
if (id) return { $ref: COMPONENT_REF_BASE + id };
|
|
117
110
|
const discriminated = (0, kizunajs_generator.readDiscriminatedUnion)(schema);
|
|
118
111
|
if (discriminated) return {
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { RoutePathSchema, definePlugin, route } from "kizunajs/plugin";
|
|
3
|
-
import { cacheHeaders, defineGenerator, deprecationHeaders, globalRegistrySchemas, isBinarySchema, isFileSchema, isNamedStream, isStreamResponse, isVoidSchema, parsePath,
|
|
3
|
+
import { cacheHeaders, defineGenerator, deprecationHeaders, encodeForWire, globalRegistrySchemas, isBinarySchema, isFileSchema, isNamedStream, isStreamResponse, isVoidSchema, parsePath, readDiscriminatedUnion, readDiscriminatorLiteral, readMeta, readMetaId, readModelSchema, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, streamContentType, streamMode, walkApi } from "kizunajs/generator";
|
|
4
4
|
import { contractOf, rawResponse } from "kizunajs/adapter";
|
|
5
5
|
import { stringify } from "yaml";
|
|
6
6
|
import { getStatusText } from "kizunajs";
|
|
@@ -79,25 +79,17 @@ const buildDiscriminatorBlock = (propertyName, options) => {
|
|
|
79
79
|
} : { propertyName };
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
82
|
-
* What the wire carries for a type JSON Schema has no keyword for, which
|
|
83
|
-
* `unrepresentable: 'any'` would otherwise leave as an empty schema.
|
|
84
|
-
*/
|
|
85
|
-
const JSON_ENCODING = {
|
|
86
|
-
date: {
|
|
87
|
-
type: "string",
|
|
88
|
-
format: "date-time"
|
|
89
|
-
},
|
|
90
|
-
bigint: { type: "string" }
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
82
|
* kizuna's metadata widens JSON Schema: `deprecated` may carry a message,
|
|
94
83
|
* `example` holds one value or several, and `brand` has no keyword. Emit
|
|
95
84
|
* `deprecated: true`, an `examples` array and `x-kizuna-brand`; the message
|
|
96
|
-
* stays in outputs with a place for it, like Swift's `@available`.
|
|
85
|
+
* stays in outputs with a place for it, like Swift's `@available`. `id` names
|
|
86
|
+
* the component, so it is dropped.
|
|
97
87
|
*/
|
|
98
88
|
const normalizeMeta = ({ zodSchema, jsonSchema }) => {
|
|
99
|
-
|
|
100
|
-
|
|
89
|
+
encodeForWire({
|
|
90
|
+
zodSchema,
|
|
91
|
+
jsonSchema
|
|
92
|
+
});
|
|
101
93
|
if (typeof jsonSchema.deprecated === "string") jsonSchema.deprecated = true;
|
|
102
94
|
if ("example" in jsonSchema) {
|
|
103
95
|
const given = Array.isArray(jsonSchema.example) ? jsonSchema.example : [jsonSchema.example];
|
|
@@ -109,9 +101,10 @@ const normalizeMeta = ({ zodSchema, jsonSchema }) => {
|
|
|
109
101
|
jsonSchema["x-kizuna-brand"] = jsonSchema.brand;
|
|
110
102
|
delete jsonSchema.brand;
|
|
111
103
|
}
|
|
104
|
+
delete jsonSchema.id;
|
|
112
105
|
};
|
|
113
106
|
const toJsonSchema = (schema, io = "output") => {
|
|
114
|
-
const id = readMetaId(schema);
|
|
107
|
+
const id = readModelSchema(schema) === schema ? readMetaId(schema) : void 0;
|
|
115
108
|
if (id) return { $ref: COMPONENT_REF_BASE + id };
|
|
116
109
|
const discriminated = readDiscriminatedUnion(schema);
|
|
117
110
|
if (discriminated) return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kizunajs/openapi",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.24",
|
|
4
4
|
"description": "OpenAPI 3.1 generation for Kizuna.js APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kizunajs",
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
"yaml": "^2.8.4"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"kizunajs": "2.0.0-beta.
|
|
62
|
+
"kizunajs": "2.0.0-beta.24",
|
|
63
63
|
"zod": "^4.0.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"kizunajs": "2.0.0-beta.
|
|
67
|
-
"@kizunajs/express": "2.0.0-beta.
|
|
66
|
+
"kizunajs": "2.0.0-beta.24",
|
|
67
|
+
"@kizunajs/express": "2.0.0-beta.24",
|
|
68
68
|
"@types/express": "^5.0.0",
|
|
69
69
|
"express": "^5.0.0",
|
|
70
70
|
"tsdown": "^0.21.0",
|