Skip to content

Commit 61ddf2b

Browse files
authored
doc: Add NestJS Example (#554)
* fix: Typos and Formatting in README of Example 8 * doc: Add NestJS Example
1 parent af84b47 commit 61ddf2b

File tree

14 files changed

+7849
-5
lines changed

14 files changed

+7849
-5
lines changed

examples/8-top-level-discriminator/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ npm start
1818

1919
## Try
2020

21-
### Discriminator with explict mapping
21+
### Discriminator with explicit mapping
2222

23-
#### `"pet_type": "cat"
23+
#### `"pet_type": "cat"`
2424

2525
```shell
2626
curl -X POST 'http://localhost:3000/v1/pets/mapping' \
@@ -32,7 +32,8 @@ npm start
3232
"pet_type": "cat"
3333
}
3434
```
35-
#### `"pet_type": "dog"
35+
36+
#### `"pet_type": "dog"`
3637

3738
```shell
3839
curl -X POST 'http://localhost:3000/v1/pets/mapping' \
@@ -45,9 +46,9 @@ curl -X POST 'http://localhost:3000/v1/pets/mapping' \
4546
}
4647
```
4748

48-
### Discriminator with implict mapping
49+
### Discriminator with implicit mapping
4950

50-
#### `"pet_type": "DogObject"
51+
#### `"pet_type": "DogObject"`
5152

5253
```shell
5354
curl -X POST 'http://localhost:3000/v1/pets/nomapping' \

examples/9-nestjs/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# NestJS Example
2+
3+
This example demonstrates how to use `express-openapi-validator` with [NestJS](https://nestjs.com/).
4+
5+
## Install
6+
7+
From this `9-nestjs` directory, run:
8+
9+
```shell
10+
npm ci
11+
```
12+
13+
## Run
14+
15+
### Start Server
16+
17+
#### Watch Mode
18+
19+
```shell
20+
npm run start
21+
```
22+
23+
or
24+
25+
```shell
26+
npm run start:dev
27+
```
28+
29+
#### Production Mode
30+
31+
```shell
32+
npm run build
33+
npm run start:prod
34+
```
35+
36+
### Requests
37+
38+
```shell
39+
curl --request GET --url http://localhost:3000/ping/foo
40+
```
41+
42+
```shell
43+
curl --request POST \
44+
--url http://localhost:3000/ping \
45+
--header 'Content-Type: application/json' \
46+
--data '{"ping": "GNU Terry Pratchett"}'
47+
```
48+
49+
## Tests
50+
51+
```shell
52+
npm run test
53+
```

examples/9-nestjs/jest.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { Config } from '@jest/types';
2+
3+
const config: Config.InitialOptions = {
4+
moduleFileExtensions: ['ts', 'js'],
5+
testMatch: ['**/*.spec.ts'],
6+
transform: {
7+
'\\.ts': 'ts-jest',
8+
},
9+
10+
testEnvironment: 'node',
11+
};
12+
export default config;

examples/9-nestjs/nest-cli.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"sourceRoot": "src",
3+
"compilerOptions": {
4+
"deleteOutDir": false,
5+
"tsConfigPath": "tsconfig.json"
6+
}
7+
}

0 commit comments

Comments
 (0)