-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field descriptions #9
Comments
Hi. I have just pushed an update to allow for this (typebox npm version Note: To allow for custom properties across all types. The signatures of // before
const T = Type.Tuple(Type.String(), Type.Number()) // [string, number]
// now
const T = Type.Tuple([Type.String(), Type.Number()])
// allowing for
const T = Type.Tuple([Type.String(), Type.Number()], { desc: 'a tuple' }) Hope that helps ! |
thanks! that's exactly what I needed! |
The linked section no longer appears in the readme, and I don't find any mention of Was this feature removed? |
@rattrayalex You can pass additional options (including const T = Type.String({ title: 'String', description: 'A basic string type' })
const T = Type.Object({
email: Type.String({ format: 'email' }),
address: Type.String({ description: 'US street address' })
}, {title: 'Customer', description: 'A customer record' }) TypeBox still provides definitions for all the known JSON schema options (so you should see these using intellisense), but you can specify your own custom properties if you wish. All properties will be applied to the underlying schema, except for properties required by the underlying type (which will be ignored, or more specifically overwritten when constructing the schema). Hope that helps. |
Got it! Very helpful. Can you add custom properties this way as well, like EDIT: I've put up a PR to the readme to clarify, assuming the answer to the above is "yes": #98 |
sinclairzx81#9 (comment) I had searched for "title", "description", "document", and "nullable" in search of how to add annotations. Many JSON Schema users use it for OpenAPI, which has the `nullable` property that isn't in JSON Schema, and may be curious how to use it. They may also wish to know whether extensions like `x-mycompany-myattribute` work.
Is it possible to use typebox to generate JSON schemas with field descriptions?
For example:
The text was updated successfully, but these errors were encountered: