Skip to content

Commit

Permalink
Merge pull request #122 from shane-js/patch-1
Browse files Browse the repository at this point in the history
Update README.md TypeScript section to recommend Ajv JSONSchemaType utility type
  • Loading branch information
simonplend authored Aug 7, 2024
2 parents 1398af0 + eedc005 commit 3b83885
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ Coming from `express-jsonschema`? Read the [migration notes](docs/migrating-from
### Schemas in TypeScript

If you're writing JSON schemas in TypeScript, you'll need to use the
`AllowedSchema` type e.g.
`AllowedSchema` type and this can be combined with [ajv's recommended `JSONSchemaType` type](https://ajv.js.org/guide/typescript.html) e.g.

```typescript
import { JSONSchemaType } from "ajv";
import { AllowedSchema } from "express-json-validator-middleware";

const addressSchema: AllowedSchema = {
type Address = { street: string; };
const addressSchema: AllowedSchema & JSONSchemaType<Address> = {
type: "object",
required: ["street"],
properties: {
Expand Down

0 comments on commit 3b83885

Please sign in to comment.