zod-nest 1.8.1 → 1.9.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 +2 -0
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -148,6 +148,8 @@ Every DTO is one Zod schema wrapped in a class. The class exists so NestJS' intr
|
|
|
148
148
|
|
|
149
149
|
The class returned by `createZodDto(schema)` carries `schema`, `id`, `io: 'input'`, and a lazy `Output` sibling. `parse` / `safeParse` are static methods on the class. The class is tagged with `Symbol.for('zod-nest.dto')` so `ZodValidationPipe` and `ZodSerializerInterceptor` can discriminate it from plain constructors. The id comes from `schema.meta({ id })` when present (preferred) or from the second-argument options.
|
|
150
150
|
|
|
151
|
+
**Naming is exposing.** Every schema put through `registerSchema()` — directly, or transitively via `createZodDto` / `@ZodBody` / `extend` / descendant discovery — lands in `components.schemas` when `applyZodNest` runs, regardless of whether any `$ref` in the doc points at it. If you give a schema `.meta({ id })`, you're declaring it documented. Anonymous schemas without an id stay inlined where used.
|
|
152
|
+
|
|
151
153
|
See [`docs/dto.md`](docs/dto.md) for the full surface.
|
|
152
154
|
|
|
153
155
|
### Schemas that don't fit a class
|
package/dist/index.js
CHANGED
|
@@ -1263,6 +1263,7 @@ var flattenObjectIntersection = /* @__PURE__ */ __name((schema, registry, decora
|
|
|
1263
1263
|
}
|
|
1264
1264
|
}
|
|
1265
1265
|
const merged = zod.z.object(mergedShape);
|
|
1266
|
+
registerSchema(schema, registry);
|
|
1266
1267
|
for (const [child, childId] of discoverDependents(schema)) {
|
|
1267
1268
|
registry.register(child, childId);
|
|
1268
1269
|
}
|
|
@@ -2147,16 +2148,35 @@ var stripMarkerFromSchema = /* @__PURE__ */ __name((schema) => {
|
|
|
2147
2148
|
}, "stripMarkerFromSchema");
|
|
2148
2149
|
|
|
2149
2150
|
// src/document/apply-zod-nest.ts
|
|
2151
|
+
var withRegistryExposure = /* @__PURE__ */ __name((collected, registry) => {
|
|
2152
|
+
const alreadyExposed = /* @__PURE__ */ new Set([
|
|
2153
|
+
...collected.inputExposedIds,
|
|
2154
|
+
...collected.outputExposedIds
|
|
2155
|
+
]);
|
|
2156
|
+
const extras = registry.ids().filter((id) => !alreadyExposed.has(id));
|
|
2157
|
+
if (extras.length === 0) {
|
|
2158
|
+
return collected;
|
|
2159
|
+
}
|
|
2160
|
+
return {
|
|
2161
|
+
inputExposedIds: /* @__PURE__ */ new Set([
|
|
2162
|
+
...collected.inputExposedIds,
|
|
2163
|
+
...extras
|
|
2164
|
+
]),
|
|
2165
|
+
outputExposedIds: collected.outputExposedIds,
|
|
2166
|
+
classToDtoId: collected.classToDtoId
|
|
2167
|
+
};
|
|
2168
|
+
}, "withRegistryExposure");
|
|
2150
2169
|
var OPENAPI_VERSION = "3.1.0";
|
|
2151
2170
|
var applyZodNest = /* @__PURE__ */ __name((doc, opts) => {
|
|
2152
2171
|
const registry = opts.registry ?? defaultRegistry;
|
|
2153
2172
|
const collected = collectUsage(doc, opts.app, registry);
|
|
2173
|
+
const exposed = withRegistryExposure(collected, registry);
|
|
2154
2174
|
const { inputSchemas, outputSchemas } = bulkEmit({
|
|
2155
2175
|
registry,
|
|
2156
2176
|
override: opts.override,
|
|
2157
2177
|
strict: opts.strict
|
|
2158
2178
|
});
|
|
2159
|
-
const extended = extendExposureViaRefs(
|
|
2179
|
+
const extended = extendExposureViaRefs(exposed, inputSchemas, outputSchemas);
|
|
2160
2180
|
const { divergentOutputIds, renames } = mergeSchemas({
|
|
2161
2181
|
doc,
|
|
2162
2182
|
inputSchemas,
|