zod-nest 3.2.6 → 3.3.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/dist/index.mjs CHANGED
@@ -1724,6 +1724,25 @@ var decorateIfPresent = /* @__PURE__ */ __name((schemas, key) => {
1724
1724
  };
1725
1725
  }, "decorateIfPresent");
1726
1726
 
1727
+ // src/document/openapi-version.ts
1728
+ var SUPPORTED_OPENAPI_SERIES = [
1729
+ "3.1",
1730
+ "3.2"
1731
+ ];
1732
+ var DEFAULT_OPENAPI_VERSION = "3.1.0";
1733
+ var SUPPORTED_VERSION_PATTERN = /^3\.[12]\.\d+(?:-.+)?$/;
1734
+ var resolveOpenApiVersion = /* @__PURE__ */ __name((doc) => {
1735
+ const declared = doc.openapi;
1736
+ if (typeof declared !== "string" || declared === "") {
1737
+ return DEFAULT_OPENAPI_VERSION;
1738
+ }
1739
+ if (SUPPORTED_VERSION_PATTERN.test(declared)) {
1740
+ return declared;
1741
+ }
1742
+ console.warn(`[zod-nest] Document declares OpenAPI \`${declared}\`, which zod-nest does not emit; emitting \`${DEFAULT_OPENAPI_VERSION}\` instead. Supported: ${SUPPORTED_OPENAPI_SERIES.map((series) => `${series}.x`).join(", ")}. Set one via \`DocumentBuilder.setOpenAPIVersion()\` to silence this.`);
1743
+ return DEFAULT_OPENAPI_VERSION;
1744
+ }, "resolveOpenApiVersion");
1745
+
1727
1746
  // src/document/ref-titles.ts
1728
1747
  var applyRefTitles = /* @__PURE__ */ __name((doc) => {
1729
1748
  const schemas = doc.components?.schemas;
@@ -1876,7 +1895,6 @@ var withForcedExposure = /* @__PURE__ */ __name((collected, registry) => {
1876
1895
  classToDtoId: collected.classToDtoId
1877
1896
  };
1878
1897
  }, "withForcedExposure");
1879
- var OPENAPI_VERSION = "3.1.0";
1880
1898
  var applyZodNest = /* @__PURE__ */ __name((doc, opts = {}) => {
1881
1899
  const registry = opts.registry ?? defaultRegistry;
1882
1900
  const collected = collectUsage(doc, registry);
@@ -1917,7 +1935,7 @@ var applyZodNest = /* @__PURE__ */ __name((doc, opts = {}) => {
1917
1935
  doc,
1918
1936
  collected: extended
1919
1937
  });
1920
- doc.openapi = OPENAPI_VERSION;
1938
+ doc.openapi = resolveOpenApiVersion(doc);
1921
1939
  return doc;
1922
1940
  }, "applyZodNest");
1923
1941