File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -77,12 +77,14 @@ Coming from `express-jsonschema`? Read the [migration notes](docs/migrating-from
77
77
### Schemas in TypeScript
78
78
79
79
If you're writing JSON schemas in TypeScript, you'll need to use the
80
- ` AllowedSchema ` type e.g.
80
+ ` AllowedSchema ` type and this can be combined with [ ajv's recommended ` JSONSchemaType ` type ] ( https://ajv.js.org/guide/typescript.html ) e.g.
81
81
82
82
``` typescript
83
+ import { JSONSchemaType } from " ajv" ;
83
84
import { AllowedSchema } from " express-json-validator-middleware" ;
84
85
85
- const addressSchema: AllowedSchema = {
86
+ type Address = { street: string ; };
87
+ const addressSchema: AllowedSchema & JSONSchemaType <Address > = {
86
88
type: " object" ,
87
89
required: [" street" ],
88
90
properties: {
You can’t perform that action at this time.
0 commit comments