@kizunajs/openapi 2.0.0-beta.22 → 2.0.0-beta.23

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
@@ -94,7 +94,8 @@ const JSON_ENCODING = {
94
94
  * kizuna's metadata widens JSON Schema: `deprecated` may carry a message,
95
95
  * `example` holds one value or several, and `brand` has no keyword. Emit
96
96
  * `deprecated: true`, an `examples` array and `x-kizuna-brand`; the message
97
- * stays in outputs with a place for it, like Swift's `@available`.
97
+ * stays in outputs with a place for it, like Swift's `@available`. `id` names
98
+ * the component, so it is dropped.
98
99
  */
99
100
  const normalizeMeta = ({ zodSchema, jsonSchema }) => {
100
101
  const encoding = JSON_ENCODING[(0, kizunajs_generator.readDef)(zodSchema).type ?? ""];
@@ -110,9 +111,10 @@ const normalizeMeta = ({ zodSchema, jsonSchema }) => {
110
111
  jsonSchema["x-kizuna-brand"] = jsonSchema.brand;
111
112
  delete jsonSchema.brand;
112
113
  }
114
+ delete jsonSchema.id;
113
115
  };
114
116
  const toJsonSchema = (schema, io = "output") => {
115
- const id = (0, kizunajs_generator.readMetaId)(schema);
117
+ const id = (0, kizunajs_generator.readModelSchema)(schema) === schema ? (0, kizunajs_generator.readMetaId)(schema) : void 0;
116
118
  if (id) return { $ref: COMPONENT_REF_BASE + id };
117
119
  const discriminated = (0, kizunajs_generator.readDiscriminatedUnion)(schema);
118
120
  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, readDef, readDiscriminatedUnion, readDiscriminatorLiteral, readMeta, readMetaId, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, streamContentType, streamMode, walkApi } from "kizunajs/generator";
3
+ import { cacheHeaders, defineGenerator, deprecationHeaders, globalRegistrySchemas, isBinarySchema, isFileSchema, isNamedStream, isStreamResponse, isVoidSchema, parsePath, readDef, 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";
@@ -93,7 +93,8 @@ const JSON_ENCODING = {
93
93
  * kizuna's metadata widens JSON Schema: `deprecated` may carry a message,
94
94
  * `example` holds one value or several, and `brand` has no keyword. Emit
95
95
  * `deprecated: true`, an `examples` array and `x-kizuna-brand`; the message
96
- * stays in outputs with a place for it, like Swift's `@available`.
96
+ * stays in outputs with a place for it, like Swift's `@available`. `id` names
97
+ * the component, so it is dropped.
97
98
  */
98
99
  const normalizeMeta = ({ zodSchema, jsonSchema }) => {
99
100
  const encoding = JSON_ENCODING[readDef(zodSchema).type ?? ""];
@@ -109,9 +110,10 @@ const normalizeMeta = ({ zodSchema, jsonSchema }) => {
109
110
  jsonSchema["x-kizuna-brand"] = jsonSchema.brand;
110
111
  delete jsonSchema.brand;
111
112
  }
113
+ delete jsonSchema.id;
112
114
  };
113
115
  const toJsonSchema = (schema, io = "output") => {
114
- const id = readMetaId(schema);
116
+ const id = readModelSchema(schema) === schema ? readMetaId(schema) : void 0;
115
117
  if (id) return { $ref: COMPONENT_REF_BASE + id };
116
118
  const discriminated = readDiscriminatedUnion(schema);
117
119
  if (discriminated) return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizunajs/openapi",
3
- "version": "2.0.0-beta.22",
3
+ "version": "2.0.0-beta.23",
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.22",
62
+ "kizunajs": "2.0.0-beta.23",
63
63
  "zod": "^4.0.0"
64
64
  },
65
65
  "devDependencies": {
66
- "kizunajs": "2.0.0-beta.22",
67
- "@kizunajs/express": "2.0.0-beta.22",
66
+ "kizunajs": "2.0.0-beta.23",
67
+ "@kizunajs/express": "2.0.0-beta.23",
68
68
  "@types/express": "^5.0.0",
69
69
  "express": "^5.0.0",
70
70
  "tsdown": "^0.21.0",