|
1
|
# medusa-oas-cli - 0.1.0 - experimental |
|
2
|
|
|
3
|
A command-line tool for all OpenAPI Specifications (OAS) related tooling. |
|
4
|
|
|
5
|
## Install |
|
6
|
|
|
7
|
`yarn add --dev @medusajs/medusa-oas-cli` |
|
8
|
|
|
9
|
Install in the global namespace is not yet supported. |
|
10
|
~~`npm install -g @medusajs/medusa-oas-cli`~~ |
|
11
|
|
|
12
|
## Configuration / First time setup |
|
13
|
|
|
14
|
N/A |
|
15
|
|
|
16
|
## How to use |
|
17
|
|
|
18
|
```bash |
|
19
|
yarn medusa-oas <command> |
|
20
|
``` |
|
21
|
|
|
22
|
--- |
|
23
|
|
|
24
|
### Command - `oas` |
|
25
|
|
|
26
|
This command will scan the `@medusajs/medusa` package in order to extract JSDoc OAS into a json file. |
|
27
|
|
|
28
|
The command will output one of three the files `admin.oas.json`, `store.oas.json` or `combined.oas.json` in the same |
|
29
|
directory that the command was run. |
|
30
|
|
|
31
|
Invalid OAS with throw an error and will prevent the files from being outputted. |
|
32
|
|
|
33
|
#### `--type <string>` |
|
34
|
|
|
35
|
Specify which API OAS to create. Accepts `admin`, `store`, `combined`. |
|
36
|
|
|
37
|
The `combined` option will merge both the admin and the store APIs into a single OAS file. |
|
38
|
|
|
39
|
```bash |
|
40
|
yarn medusa-oas oas --type admin |
|
41
|
``` |
|
42
|
|
|
43
|
#### `--out-dir <path>` |
|
44
|
|
|
45
|
Specify in which directory should the files be outputted. It accepts a relative or absolute path. |
|
46
|
If the directory doesn't exist, it will be created. Defaults to `./`. |
|
47
|
|
|
48
|
```bash |
|
49
|
yarm medusa-oas oas --out-dir |
|
50
|
``` |
|
51
|
|
|
52
|
#### `--paths <paths...>` |
|
53
|
|
|
54
|
Allows passing additional directory paths to crawl for JSDoc OAS and include in the generated OAS. |
|
55
|
It accepts multiple entries. |
|
56
|
|
|
57
|
```bash |
|
58
|
yarn medusa-oas oas --paths ~/medusa-server/src |
|
59
|
``` |
|
60
|
|
|
61
|
#### `--base <path>` |
|
62
|
|
|
63
|
Allows overwriting the content the API's base.yaml OAS that is fed to swagger-inline. |
|
64
|
Paths, tags, and components will be merged together. Other OAS properties will be overwritten. |
|
65
|
|
|
66
|
```bash |
|
67
|
yarn medusa-oas oas --base ~/medusa-server/oas/custom.oas.base.yaml |
|
68
|
``` |
|
69
|
|
|
70
|
#### `--dry-run` |
|
71
|
|
|
72
|
Will package the OAS but will not output file. Useful for validating OAS. |
|
73
|
|
|
74
|
```bash |
|
75
|
yarn medusa-oas oas --dry-run |
|
76
|
``` |
|
77
|
|
|
78
|
#### `--force` |
|
79
|
|
|
80
|
Ignore OAS errors and attempt to output generated OAS files. |
|
81
|
|
|
82
|
```bash |
|
83
|
yarn medusa-oas oas --force |
|
84
|
``` |
|
85
|
|
|
86
|
--- |
|
87
|
|
|
88
|
### Command - `docs` |
|
89
|
|
|
90
|
Will sanitize OAS for use with Redocly's API documentation viewer. |
|
91
|
|
|
92
|
#### `--src-file <path>` |
|
93
|
|
|
94
|
Specify the path to the OAS JSON file. |
|
95
|
|
|
96
|
```bash |
|
97
|
yarm medusa-oas docs --src-file ./store.oas.json |
|
98
|
``` |
|
99
|
|
|
100
|
#### `--out-dir <path>` |
|
101
|
|
|
102
|
Specify in which directory should the files be outputted. Accepts relative and absolute path. |
|
103
|
If the directory doesn't exist, it will be created. Defaults to `./`. |
|
104
|
|
|
105
|
```bash |
|
106
|
yarn medusa-oas docs --src-file ./store.oas.json --out-dir ./docs` |
|
107
|
``` |
|
108
|
|
|
109
|
#### `--config <path>` |
|
110
|
|
|
111
|
Specify the path to a Redocly config file. |
|
112
|
|
|
113
|
```bash |
|
114
|
yarn medusa-oas --src-file ./store.oas.json --config ./redocly-config.yaml |
|
115
|
``` |
|
116
|
|
|
117
|
#### `--dry-run` |
|
118
|
|
|
119
|
Will sanitize the OAS but will not output file. Useful for troubleshooting circular reference issues. |
|
120
|
|
|
121
|
```bash |
|
122
|
yarn medusa-oas docs --src-file ./store.oas.json --dry-run |
|
123
|
``` |
|
124
|
|
|
125
|
#### `--clean` |
|
126
|
|
|
127
|
Delete destination directory content before generating the docs. |
|
128
|
|
|
129
|
```bash |
|
130
|
yarn medusa-oas docs --src-file ./store.oas.json --clean |
|
131
|
``` |
|
132
|
|
|
133
|
#### `--split` |
|
134
|
|
|
135
|
Creates a multi-file structure output. Uses `redocly split` internally. |
|
136
|
|
|
137
|
```bash |
|
138
|
yarn medusa-oas docs --src-file ./store.oas.json --split |
|
139
|
``` |
|
140
|
|
|
141
|
#### `--preview` |
|
142
|
|
|
143
|
Generate a preview of the API documentation in a browser. Does not output files. Uses `redocly preview-docs` internally. |
|
144
|
|
|
145
|
```bash |
|
146
|
yarn medusa-oas docs --src-file ../../../www/apps/api-reference/specs/store.oas.json --preview |
|
147
|
``` |
|
148
|
|
|
149
|
#### `--html` |
|
150
|
|
|
151
|
Generate a zero-dependency static HTML file. Uses `redocly build-docs` internally. |
|
152
|
|
|
153
|
```bash |
|
154
|
yarn medusa-oas docs --src-file ./store.oas.json --html |
|
155
|
``` |