@kizunajs/openapi 2.0.0-beta.3 → 2.0.0-beta.4

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,12 +80,25 @@ 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
+ /**
83
94
  * kizuna's metadata widens JSON Schema: `deprecated` may carry a message and
84
95
  * `example` holds one value or several. Emit `deprecated: true` and an
85
96
  * `examples` array; the message stays in outputs with a place for it, like
86
97
  * Swift's `@available`.
87
98
  */
88
- const normalizeMeta = ({ jsonSchema }) => {
99
+ const normalizeMeta = ({ zodSchema, jsonSchema }) => {
100
+ const encoding = JSON_ENCODING[(0, kizunajs_generator.readDef)(zodSchema).type ?? ""];
101
+ if (encoding && Object.keys(jsonSchema).length === 0) Object.assign(jsonSchema, encoding);
89
102
  if (typeof jsonSchema.deprecated === "string") jsonSchema.deprecated = true;
90
103
  if ("example" in jsonSchema) {
91
104
  const given = Array.isArray(jsonSchema.example) ? jsonSchema.example : [jsonSchema.example];
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { createPlugin } from "kizunajs/plugin";
3
3
  import { contractOf, rawResponse } from "kizunajs/adapter";
4
4
  import { stringify } from "yaml";
5
- import { cacheHeaders, createGenerator, deprecationHeaders, globalRegistrySchemas, isBinarySchema, isFileSchema, isNamedStream, isStreamResponse, isVoidSchema, parsePath, readDiscriminatedUnion, readDiscriminatorLiteral, readMeta, readMetaId, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, streamContentType, streamMode } from "kizunajs/generator";
5
+ import { cacheHeaders, createGenerator, deprecationHeaders, globalRegistrySchemas, isBinarySchema, isFileSchema, isNamedStream, isStreamResponse, isVoidSchema, parsePath, readDef, readDiscriminatedUnion, readDiscriminatorLiteral, readMeta, readMetaId, readObjectShape, resolveResponseBody, resolveResponseCache, resolveResponseContentType, resolveResponseEtag, resolveResponseHeaders, streamContentType, streamMode } from "kizunajs/generator";
6
6
  import { getStatusText } from "kizunajs";
7
7
  //#region src/generator.ts
8
8
  const streamJsonSchema = (response, toJsonSchema) => {
@@ -79,12 +79,25 @@ 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
+ /**
82
93
  * kizuna's metadata widens JSON Schema: `deprecated` may carry a message and
83
94
  * `example` holds one value or several. Emit `deprecated: true` and an
84
95
  * `examples` array; the message stays in outputs with a place for it, like
85
96
  * Swift's `@available`.
86
97
  */
87
- const normalizeMeta = ({ jsonSchema }) => {
98
+ const normalizeMeta = ({ zodSchema, jsonSchema }) => {
99
+ const encoding = JSON_ENCODING[readDef(zodSchema).type ?? ""];
100
+ if (encoding && Object.keys(jsonSchema).length === 0) Object.assign(jsonSchema, encoding);
88
101
  if (typeof jsonSchema.deprecated === "string") jsonSchema.deprecated = true;
89
102
  if ("example" in jsonSchema) {
90
103
  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.3",
3
+ "version": "2.0.0-beta.4",
4
4
  "description": "OpenAPI 3.1 generation for Kizuna.js APIs",
5
5
  "keywords": [
6
6
  "kizunajs",
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "peerDependencies": {
62
62
  "zod": "^4.0.0",
63
- "kizunajs": "2.0.0-beta.3"
63
+ "kizunajs": "2.0.0-beta.4"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/express": "^5.0.0",
@@ -68,8 +68,8 @@
68
68
  "tsdown": "^0.21.0",
69
69
  "typescript": "^6.0.3",
70
70
  "zod": "^4.0.0",
71
- "@kizunajs/express": "2.0.0-beta.3",
72
- "kizunajs": "2.0.0-beta.3"
71
+ "kizunajs": "2.0.0-beta.4",
72
+ "@kizunajs/express": "2.0.0-beta.4"
73
73
  },
74
74
  "scripts": {
75
75
  "build": "tsdown src/index.ts --format esm,cjs --dts --clean --external kizunajs --external zod",