zod-openapi 2.4.0-beta.1 → 2.4.0

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/README.md CHANGED
@@ -276,9 +276,7 @@ const title = z.string().openapi({
276
276
  Wherever `title` is used in schemas across the document, it will instead be created as a reference.
277
277
 
278
278
  ```json
279
- {
280
- "title": { "$ref": "#/components/schemas/jobTitle" }
281
- }
279
+ { "$ref": "#/components/schemas/jobTitle" }
282
280
  ```
283
281
 
284
282
  `title` will then be outputted as a schema within the components section of the documentation.
@@ -309,7 +307,7 @@ eg.
309
307
  createDocument({
310
308
  components: {
311
309
  schemas: {
312
- jobTitle, // this will register this Zod Schema as jobTitle unless `ref` in `.openapi()` is specified on the type
310
+ jobTitle: title, // this will register this Zod Schema as jobTitle unless `ref` in `.openapi()` is specified on the type
313
311
  },
314
312
  },
315
313
  });
@@ -323,7 +321,7 @@ If a registered schema with a transform or pipeline is used in both a request an
323
321
 
324
322
  `.preprocess()` will always return the `output` type even if we are creating an input schema. If a different input type is required you can achieve this with a `.transform()` combined with a `.pipe()` or simply declare a manual `type` in `.openapi()`.
325
323
 
326
- If you are adding the ZodSchema directly to the `components` section which is not referenced anywhere in the document, context may required with knowing to create an input schema or an output schema. You can do this by setting the `refType` field to `input` or `output` in `.openapi()`. This defaults to `output` by default.
324
+ If you are adding a ZodSchema directly to the `components` section which is not referenced anywhere in the document, additional context may be required to create either an input schema or an output schema. You can do this by setting the `refType` field to `input` or `output` in `.openapi()`. This defaults to `output` by default.
327
325
 
328
326
  #### Parameters
329
327
 
@@ -501,6 +499,7 @@ For example in `z.string().nullable()` will be rendered differently
501
499
  - `refine` full support
502
500
  - ZodEnum
503
501
  - ZodLazy
502
+ - The recursive schema within the ZodLazy or the ZodLazy _**must**_ be registered as a component. See [Creating Components](#creating-components) for more information.
504
503
  - ZodLiteral
505
504
  - ZodNativeEnum
506
505
  - supporting `string`, `number` and combined enums.
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./create/document"), exports);
18
18
  __exportStar(require("./extendZod"), exports);
19
+ __exportStar(require("./openapi3-ts/dist"), exports);
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,8CAA4B;AAC5B,qDAAmC"}
@@ -23,10 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ServerVariable = exports.Server = exports.oas31 = exports.oas30 = void 0;
26
+ exports.oas31 = exports.oas30 = void 0;
27
27
  exports.oas30 = __importStar(require("./oas30"));
28
28
  exports.oas31 = __importStar(require("./oas31"));
29
- var server_1 = require("./model/server");
30
- Object.defineProperty(exports, "Server", { enumerable: true, get: function () { return server_1.Server; } });
31
- Object.defineProperty(exports, "ServerVariable", { enumerable: true, get: function () { return server_1.ServerVariable; } });
32
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/openapi3-ts/dist/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAiC;AACjC,iDAAiC;AACjC,yCAAwD;AAA/C,gGAAA,MAAM,OAAA;AAAE,wGAAA,cAAc,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/openapi3-ts/dist/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAiC;AACjC,iDAAiC"}
@@ -14,10 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ServerVariable = exports.Server = void 0;
18
17
  __exportStar(require("./dsl/openapi-builder30"), exports);
19
18
  __exportStar(require("./model/openapi30"), exports);
20
- var server_1 = require("./model/server");
21
- Object.defineProperty(exports, "Server", { enumerable: true, get: function () { return server_1.Server; } });
22
- Object.defineProperty(exports, "ServerVariable", { enumerable: true, get: function () { return server_1.ServerVariable; } });
23
19
  //# sourceMappingURL=oas30.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"oas30.js","sourceRoot":"","sources":["../../../src/openapi3-ts/dist/oas30.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,oDAAkC;AAClC,yCAAwD;AAA/C,gGAAA,MAAM,OAAA;AAAE,wGAAA,cAAc,OAAA"}
1
+ {"version":3,"file":"oas30.js","sourceRoot":"","sources":["../../../src/openapi3-ts/dist/oas30.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,oDAAkC"}
@@ -14,10 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.ServerVariable = exports.Server = void 0;
18
17
  __exportStar(require("./dsl/openapi-builder31"), exports);
19
18
  __exportStar(require("./model/openapi31"), exports);
20
- var server_1 = require("./model/server");
21
- Object.defineProperty(exports, "Server", { enumerable: true, get: function () { return server_1.Server; } });
22
- Object.defineProperty(exports, "ServerVariable", { enumerable: true, get: function () { return server_1.ServerVariable; } });
23
19
  //# sourceMappingURL=oas31.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"oas31.js","sourceRoot":"","sources":["../../../src/openapi3-ts/dist/oas31.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,oDAAkC;AAClC,yCAAwD;AAA/C,gGAAA,MAAM,OAAA;AAAE,wGAAA,cAAc,OAAA"}
1
+ {"version":3,"file":"oas31.js","sourceRoot":"","sources":["../../../src/openapi3-ts/dist/oas31.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,oDAAkC"}
@@ -1,3 +1,4 @@
1
1
  export * from './create/document';
2
2
  export * from './extendZod';
3
+ export * from './openapi3-ts/dist';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
@@ -2,5 +2,4 @@ import * as oas30_1 from "./oas30";
2
2
  export { oas30_1 as oas30 };
3
3
  import * as oas31_1 from "./oas31";
4
4
  export { oas31_1 as oas31 };
5
- export { Server, ServerVariable } from "./model/server";
6
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/openapi3-ts/dist/index.ts"],"names":[],"mappings":"yBAAuB,SAAS;oBAApB,KAAK;yBACM,SAAS;oBAApB,KAAK;AACjB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/openapi3-ts/dist/index.ts"],"names":[],"mappings":"yBAAuB,SAAS;oBAApB,KAAK;yBACM,SAAS;oBAApB,KAAK"}
@@ -1,4 +1,3 @@
1
1
  export * from './dsl/openapi-builder30';
2
2
  export * from './model/openapi30';
3
- export { Server, ServerVariable } from './model/server';
4
3
  //# sourceMappingURL=oas30.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"oas30.js","sourceRoot":"","sources":["../../../src/openapi3-ts/dist/oas30.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"oas30.js","sourceRoot":"","sources":["../../../src/openapi3-ts/dist/oas30.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
@@ -1,4 +1,3 @@
1
1
  export * from './dsl/openapi-builder31';
2
2
  export * from './model/openapi31';
3
- export { Server, ServerVariable } from './model/server';
4
3
  //# sourceMappingURL=oas31.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"oas31.js","sourceRoot":"","sources":["../../../src/openapi3-ts/dist/oas31.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"oas31.js","sourceRoot":"","sources":["../../../src/openapi3-ts/dist/oas31.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export * from './create/document';
2
2
  export * from './extendZod';
3
- export type * from './openapi3-ts/dist';
3
+ export * from './openapi3-ts/dist';
@@ -1,3 +1,3 @@
1
1
  export * as oas30 from "./oas30";
2
2
  export * as oas31 from "./oas31";
3
- export { Server, ServerVariable } from "./model/server";
3
+ export type { Server, ServerVariable } from "./model/server";
@@ -1,4 +1,4 @@
1
1
  export * from './dsl/openapi-builder30';
2
2
  export * from './model/openapi30';
3
- export { Server, ServerVariable } from './model/server';
3
+ export type { Server, ServerVariable } from './model/server';
4
4
  export type { IExtensionName, IExtensionType, ISpecificationExtension } from './model/specification-extension';
@@ -1,4 +1,4 @@
1
1
  export * from './dsl/openapi-builder31';
2
2
  export * from './model/openapi31';
3
- export { Server, ServerVariable } from './model/server';
3
+ export type { Server, ServerVariable } from './model/server';
4
4
  export type { IExtensionName, IExtensionType, ISpecificationExtension } from './model/specification-extension';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-openapi",
3
- "version": "2.4.0-beta.1",
3
+ "version": "2.4.0",
4
4
  "description": "A library to create full OpenAPI documents from your Zod types",
5
5
  "homepage": "https://github.com/samchungy/zod-openapi#readme",
6
6
  "bugs": {