configToJSONSchema improvements #12744
Dutch77
started this conversation in
Feature Requests & Ideas
Replies: 1 comment
-
for now I solved my issue with plugin. import { Config, Plugin } from 'payload'
export const fieldSchemaFix = (): Plugin => {
return async (config: Config): Promise<Config> => {
config.onInit = (payload) => {
payload.config.collections.forEach((collection) => {
collection.fields.forEach((field) => {
if (field.type === 'date') {
field.typescriptSchema = [
() => {
return {
type: 'string',
format: 'date-time',
}
},
]
}
})
})
}
return config
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm currently using this https://github.com/payloadcms/payload/blob/main/packages/payload/src/utilities/configToJSONSchema.ts#L365
to generate some json schemas. What bothers me is lack extra information like:
date
but result field schema is only{"type": "string"}
but could be{"type": "string", "format": "date-time"}
email
again only{"type": "string"}
...
Is this on some purpose or is there a room for improvements (PR)?
For example this plugin https://github.com/janbuchar/payload-oapi uses this schema for automatic openapi schema specification and lack of extra information is also limiting factor there, it can be much more precise.
Thanks for any response :)
Beta Was this translation helpful? Give feedback.
All reactions