balda-js 0.0.46 → 0.0.48

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/lib/index.cjs CHANGED
@@ -4339,10 +4339,16 @@ function generateOpenAPISpec(globalOptions) {
4339
4339
  const routes = router.getRoutes();
4340
4340
  const paths = {};
4341
4341
  if (Array.isArray(globalOptions.models)) {
4342
- globalOptions.models = globalOptions.models.reduce((acc, model) => {
4343
- acc[model.$id || "name"] = model;
4344
- return acc;
4345
- }, {});
4342
+ globalOptions.models = globalOptions.models.reduce(
4343
+ (acc, model, index) => {
4344
+ const isZodSchema = model && typeof model === "object" && "_def" in model;
4345
+ const jsonSchema = isZodSchema ? safeToJSONSchema(model) : model;
4346
+ const schemaName = jsonSchema.$id || jsonSchema.title || `Model${index}`;
4347
+ acc[schemaName] = jsonSchema;
4348
+ return acc;
4349
+ },
4350
+ {}
4351
+ );
4346
4352
  }
4347
4353
  const components = {
4348
4354
  ...globalOptions.components,