@@ -28,20 +28,32 @@ View examples:
28
28
``` bash
29
29
npx openapi-typescript schema.yaml --output schema.ts
30
30
31
- # 🤞 Loading spec from tests/v2/specs/stripe .yaml…
31
+ # 🔭 Loading spec from schema .yaml…
32
32
# 🚀 schema.yaml -> schema.ts [250ms]
33
+
34
+ npx openapi-typescript " specs/**/*.yaml" --output schemas/
35
+ # 🔭 Loading spec from specs/one.yaml…
36
+ # 🔭 Loading spec from specs/two.yaml…
37
+ # 🔭 Loading spec from specs/three.yaml…
38
+ # 🚀 specs/one.yaml -> schemas/one.ts [250ms]
39
+ # 🚀 specs/two.yaml -> schemas/two.ts [250ms]
40
+ # 🚀 specs/three.yaml -> schemas/three.ts [250ms]
33
41
```
34
42
43
+ _ Thanks to [ @sharmarajdaksh ] ( https://github.com/sharmarajdaksh ) for the glob feature!_
44
+
35
45
#### ☁️ Reading specs from remote resource
36
46
37
47
``` bash
38
48
npx openapi-typescript https://petstore.swagger.io/v2/swagger.json --output petstore.ts
39
49
40
- # 🤞 Loading spec from https://petstore.swagger.io/v2/swagger.json…
50
+ # 🔭 Loading spec from https://petstore.swagger.io/v2/swagger.json…
41
51
# 🚀 https://petstore.swagger.io/v2/swagger.json -> petstore.ts [650ms]
42
52
```
43
53
44
- _ Thanks to @psmyrdek for the remote spec feature!_
54
+ _ Note: for obvious reasons, globbing doesn’t work for remote schemas_
55
+
56
+ _ Thanks to [ @psmyrdek ] ( https://github.com/psmyrdek ) for the remote spec feature!_
45
57
46
58
#### Using in TypeScript
47
59
@@ -73,37 +85,6 @@ _Thanks to @gr2m for the operations feature!_
73
85
npx openapi-typescript schema.yaml
74
86
```
75
87
76
- #### Generating multiple schemas
77
-
78
- In your ` package.json ` , for each schema you’d like to transform add one ` generate:specs:[name] ` npm-script. Then combine
79
- them all into one ` generate:specs ` script, like so:
80
-
81
- ``` json
82
- "scripts" : {
83
- "generate:specs" : " npm run generate:specs:one && npm run generate:specs:two && npm run generate:specs:three" ,
84
- "generate:specs:one" : " npx openapi-typescript one.yaml -o one.ts" ,
85
- "generate:specs:two" : " npx openapi-typescript two.yaml -o two.ts" ,
86
- "generate:specs:three" : " npx openapi-typescript three.yaml -o three.ts"
87
- }
88
- ```
89
-
90
- If you use [ npm-run-all] [ npm-run-all ] , you can shorten this:
91
-
92
- ``` json
93
- "scripts" : {
94
- "generate:specs" : " run-p generate:specs:*" ,
95
- ```
96
-
97
- You can even specify unique options per-spec, if needed. To generate them all together, run:
98
-
99
- ```bash
100
- npm run generate:specs
101
- ```
102
-
103
- Rinse and repeat for more specs.
104
-
105
- For anything more complicated, or for generating specs dynamically, you can also use the [Node API](#node).
106
-
107
88
#### CLI Options
108
89
109
90
| Option | Alias | Default | Description |
0 commit comments