@@ -27,7 +27,7 @@ To compare actual generated output, see the [example](./example) folder.
2727``` bash
2828npx @manifoldco/swagger-to-ts schema.yaml --wrapper " declare namespace OpenAPI" --output schema.d.ts
2929
30- # 🚀 schema.yaml -> schema.ts [2ms]
30+ # 🚀 schema.yaml -> schema.d. ts [2ms]
3131```
3232
3333This will save a ` schema.ts ` file in the current folder under the TypeScript
@@ -51,7 +51,7 @@ the `{}`):
5151
5252``` bash
5353npx @manifoldco/swagger-to-ts schema.yaml --wrapper " namespace API"
54- npx @manifoldco/swagger-to-ts schema.yaml --wrapper " declare namespace API"
54+ npx @manifoldco/swagger-to-ts schema.yaml --wrapper " export namespace API"
5555npx @manifoldco/swagger-to-ts schema.yaml --wrapper " declare namespace API"
5656npx @manifoldco/swagger-to-ts schema.yaml --wrapper " declare module '@api'"
5757```
@@ -70,9 +70,9 @@ Within interfaces, you may want to convert `snake_case` properties to
7070` camelCase ` by adding the ` --camelcase ` flag:
7171
7272``` bash
73- npx @manifoldco/swagger-to-ts schema.yaml --wrapper " declare namespace OpenAPI" --output schema.d.ts
73+ npx @manifoldco/swagger-to-ts schema.yaml --camelcase -- wrapper " declare namespace OpenAPI" --output schema.d.ts
7474
75- # 🚀 schema.yaml -> schema.ts [2ms]
75+ # 🚀 schema.yaml -> schema.d. ts [2ms]
7676```
7777
7878#### Generating multiple schemas
@@ -84,8 +84,8 @@ something like the following:
8484``` json
8585"scripts" : {
8686 "generate:specs" : " npm run generate:specs:one && npm run generate:specs:two" ,
87- "generate:specs:one" : " npx @manifoldco/swagger-to-ts one.yaml -o one.ts" ,
88- "generate:specs:two" : " npx @manifoldco/swagger-to-ts two.yaml -o two.ts"
87+ "generate:specs:one" : " npx @manifoldco/swagger-to-ts one.yaml -o one.d. ts" ,
88+ "generate:specs:two" : " npx @manifoldco/swagger-to-ts two.yaml -o two.d. ts"
8989}
9090```
9191
@@ -113,27 +113,24 @@ npm i --save-dev @manifoldco/swagger-to-ts
113113const { readFileSync } = require (' fs' );
114114const swaggerToTS = require (' @manifoldco/swagger-to-ts' );
115115
116- const input = JSON .parse (readFileSync (' spec.json' , ' utf8' )); // Input be any JS object (OpenAPI format)
116+ const input = JSON .parse (readFileSync (' spec.json' , ' utf8' )); // Input can be any JS object (OpenAPI format)
117117const output = swaggerToTS (input, { wrapper: ' declare namespace MyAPI' }); // Outputs TypeScript defs as a string (to be parsed, or written to a file)
118118```
119119
120120The Node API is a bit more flexible: it will only take a JS object as input
121121(OpenAPI format), and return a string of TS definitions. This lets you pull
122- from any source (a Swagger server, local files, etc.), and similarly lets put
123- the output anywhere. It even allows for some post-processing in-between if
124- desired.
122+ from any source (a Swagger server, local files, etc.), and similarly lets you
123+ parse, post-process, and save the output anywhere.
125124
126- If you are working with local files, you’ll have to read/write files
127- yourself. Also, if your specs are in YAML, you’ll have to convert them to JS
128- objects. A library such as [ js-yaml] [ js-yaml ] does make this trivial, though!
129- Lastly, if you’re batching large folders of specs, [ glob] [ glob ] may also come
130- in handy.
125+ If your specs are in YAML, you’ll have to convert them to JS objects using a
126+ library such as [ js-yaml] [ js-yaml ] . If you’re batching large folders of
127+ specs, [ glob] [ glob ] may also come in handy.
131128
132129#### Node Options
133130
134131| Name | Type | Default | Description |
135132| :---------- | :-------: | :--------------------------: | :--------------------------------------------------------- |
136- | ` -- wrapper` | ` string ` | ` declare namespace OpenAPI2 ` | How should this export the types? |
133+ | ` wrapper ` | ` string ` | ` declare namespace OpenAPI2 ` | How should this export the types? |
137134| ` swagger ` | ` number ` | ` 2 ` | Which Swagger version to use. Currently only supports ` 2 ` . |
138135| ` camelcase ` | ` boolean ` | ` false ` | Convert ` snake_case ` properties to ` camelCase ` |
139136
0 commit comments