You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check if the field `main` in your package.json pointing to the file where the node server exported.
18
+
19
+
If not, add `output.main` pointing to the file, e.g.:
20
+
21
+
```json
22
+
{
23
+
...
24
+
"outdoc": {
25
+
"main": "./server/index.js"
26
+
}
27
+
}
28
+
```
29
+
30
+
## Usage
31
+
32
+
```bash
33
+
$ npx outdoc [test command] [options]
34
+
```
35
+
36
+
Usually it could be:
37
+
38
+
```bash
39
+
$ npx outdoc npm test -t project-name
40
+
```
41
+
And it will generate an api.yaml in your root folder by default
42
+
43
+
## Options
44
+
45
+
```
46
+
-o, --output file path of the generated doc, format supports json and yaml, default: api.yaml
47
+
-t, --title <string> title of the api document, default: API Document
48
+
-v, --version <string> version of the api document, default: 1.0.0
49
+
-e, --email <string> contact information
50
+
-h, --help display help for command
51
+
```
52
+
53
+
54
+
## Typescript projects
55
+
Add `output.main` in your package.json pointing to the file where the nodejs server exported, e.g.:
56
+
57
+
```json
58
+
{
59
+
...
60
+
"outdoc": {
61
+
"main": "./src/app.ts"
62
+
}
63
+
}
64
+
65
+
```
66
+
afte that you can run the script as usual
67
+
68
+
69
+
## Behind the screen
70
+
71
+
Outdoc make use the node module `async_hooks` to understand all the HTTP request to the nodejs server.
72
+
73
+
When you running the e2e testing, you are like telling outdoc "ok, this is a 200 request if you pass in such request body", "and this endpoint can return 403 with a code 100", etc. Outdoc will generate the api doc based on that.
74
+
75
+
So if you wanna have a completed API doc, you need
76
+
1. Writing e2e test covering all the cases of your API.
77
+
2. Running e2e test with real http request, that means testing tools like supertest is a fit, but fastify.inject won't work.
0 commit comments