@kizunajs/openapi 2.0.0-beta.23 → 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 CHANGED
@@ -80,17 +80,6 @@ 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
@@ -98,8 +87,10 @@ const JSON_ENCODING = {
98
87
  * the component, so it is dropped.
99
88
  */
100
89
  const normalizeMeta = ({ zodSchema, jsonSchema }) => {
101
- const encoding = JSON_ENCODING[(0, kizunajs_generator.readDef)(zodSchema).type ?? ""];
102
- if (encoding && Object.keys(jsonSchema).length === 0) Object.assign(jsonSchema, encoding);
90
+ (0, kizunajs_generator.encodeForWire)({
91
+ zodSchema,
92
+ jsonSchema
93
+ });
103
94
  if (typeof jsonSchema.deprecated === "string") jsonSchema.deprecated = true;
104
95
  if ("example" in jsonSchema) {
105
96
  const given = Array.isArray(jsonSchema.example) ? jsonSchema.example : [jsonSchema.example];
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, readModelSchema, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, streamContentType, streamMode, walkApi } from "kizunajs/generator";
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,17 +79,6 @@ 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
@@ -97,8 +86,10 @@ const JSON_ENCODING = {
97
86
  * the component, so it is dropped.
98
87
  */
99
88
  const normalizeMeta = ({ zodSchema, jsonSchema }) => {
100
- const encoding = JSON_ENCODING[readDef(zodSchema).type ?? ""];
101
- if (encoding && Object.keys(jsonSchema).length === 0) Object.assign(jsonSchema, encoding);
89
+ encodeForWire({
90
+ zodSchema,
91
+ jsonSchema
92
+ });
102
93
  if (typeof jsonSchema.deprecated === "string") jsonSchema.deprecated = true;
103
94
  if ("example" in jsonSchema) {
104
95
  const given = Array.isArray(jsonSchema.example) ? jsonSchema.example : [jsonSchema.example];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizunajs/openapi",
3
- "version": "2.0.0-beta.23",
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.23",
62
+ "kizunajs": "2.0.0-beta.24",
63
63
  "zod": "^4.0.0"
64
64
  },
65
65
  "devDependencies": {
66
- "kizunajs": "2.0.0-beta.23",
67
- "@kizunajs/express": "2.0.0-beta.23",
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",