Describe the feature
For such zod schema:
const UserSchema = z
.object({
name: z.string(),
})
.meta({
id: "User",
deprecated: false,
description: "A user object",
title: "A User",
});
If zod schema has id field in the global zod registry(which means it was declared with .meta({id: "SchemaName"})) then extract it to components.schemas and reuse from from other places when generating a spec.
So the openapi spec would include:
{
"paths": {/* ... */},
"components": {
"schemas": {
"User": {
"required": ["name"],
"properties": {
"name": {
"type": "string"
}
}
}
}
}
}
With current approaches:
Using common schemas https://orpc.dev/docs/openapi/openapi-specification#common-schemas - all schemas should be manually declared in one place.
And with https://orpc.dev/docs/openapi/openapi-specification#json-schema-customization only description and examples are supported from zod .meta field.
There is also https://github.com/standard-community/standard-openapi which potentially can be used to have this for all validators not just for zod.
Describe the feature
For such zod schema:
If zod schema has id field in the global zod registry(which means it was declared with
.meta({id: "SchemaName"}))then extract it tocomponents.schemasand reuse from from other places when generating a spec.So the openapi spec would include:
{ "paths": {/* ... */}, "components": { "schemas": { "User": { "required": ["name"], "properties": { "name": { "type": "string" } } } } } }With current approaches:
Using common schemas https://orpc.dev/docs/openapi/openapi-specification#common-schemas - all schemas should be manually declared in one place.
And with https://orpc.dev/docs/openapi/openapi-specification#json-schema-customization only
descriptionandexamplesare supported from zod.metafield.There is also https://github.com/standard-community/standard-openapi which potentially can be used to have this for all validators not just for zod.