You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: support for multiple schema types simultaneously (#46)
* feat: add support for multiple schema types and custom OpenAPI files
- Add support for schemaType as string or array (e.g., ["zod", "typescript"])
- Add schemaFiles config option for custom YAML/JSON OpenAPI schemas
- Implement priority-based schema resolution (custom files > zod > typescript)
- Add js-yaml dependency for YAML parsing
- Update SchemaProcessor to handle multiple schema sources simultaneously
- Maintain backward compatibility with existing single schemaType config
- Update types and OpenAPI template with new configuration options
* docs: add next15-app-mixed-schemas example demonstrating multiple schema types
- Add complete working example using Zod, TypeScript, and custom YAML schemas
- Include API routes for users, products, orders, and roles
- Demonstrate schema priority with custom openapi-models.yaml
- Add comprehensive README with setup instructions
- Update main README with Multiple Schema Types section
* docs: simplify README.md
* docs: fix typo in readme.md
* chore: update package.json for next15-app-mixed-schemas
See the [complete Drizzle-Zod example](./examples/next15-app-drizzle-zod) for a full working implementation with a blog API.
768
767
768
+
## Multiple Schema Types Support 🆕
769
+
770
+
Use **multiple schema types simultaneously** in a single project - perfect for gradual migrations, combining hand-written schemas with generated ones (protobuf, GraphQL), or using existing OpenAPI specs.
771
+
772
+
### Configuration
773
+
774
+
```json
775
+
{
776
+
"schemaType": ["zod", "typescript"],
777
+
"schemaDir": "./src/schemas",
778
+
"schemaFiles": ["./schemas/external-api.yaml"]
779
+
}
780
+
```
781
+
782
+
### Schema Resolution Priority
783
+
784
+
1.**Custom files** (highest) - from `schemaFiles` array
785
+
2.**Zod schemas** (medium) - if `"zod"` in `schemaType`
786
+
3.**TypeScript types** (fallback) - if `"typescript"` in `schemaType`
787
+
788
+
### Common Use Cases
789
+
790
+
```json
791
+
// Gradual TypeScript → Zod migration
792
+
{ "schemaType": ["zod", "typescript"] }
793
+
794
+
// Zod + protobuf schemas
795
+
{
796
+
"schemaType": ["zod"],
797
+
"schemaFiles": ["./proto/schemas.yaml"]
798
+
}
799
+
800
+
// Everything together
801
+
{
802
+
"schemaType": ["zod", "typescript"],
803
+
"schemaFiles": ["./openapi-models.yaml"]
804
+
}
805
+
```
806
+
807
+
Custom schema files support YAML/JSON in OpenAPI 3.0 format. See **[next15-app-mixed-schemas](./examples/next15-app-mixed-schemas)** for a complete working example.
808
+
769
809
## Examples
770
810
771
811
This repository includes several complete example projects:
0 commit comments