Skip to content

Commit c48acee

Browse files
authored
README changes (#16)
* 1.2.1 * Clean up README
1 parent 62d635f commit c48acee

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ To compare actual generated output, see the [example](./example) folder.
2727
```bash
2828
npx @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

3333
This will save a `schema.ts` file in the current folder under the TypeScript
@@ -51,7 +51,7 @@ the `{}`):
5151

5252
```bash
5353
npx @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"
5555
npx @manifoldco/swagger-to-ts schema.yaml --wrapper "declare namespace API"
5656
npx @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
113113
const { readFileSync } = require('fs');
114114
const 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)
117117
const output = swaggerToTS(input, { wrapper: 'declare namespace MyAPI' }); // Outputs TypeScript defs as a string (to be parsed, or written to a file)
118118
```
119119

120120
The 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

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@manifoldco/swagger-to-ts",
33
"description": "Generate TypeScript types from Swagger OpenAPI specs",
44
"main": "dist/cjs",
5-
"version": "1.2.0",
5+
"version": "1.2.1",
66
"engines": {
77
"node": ">= 8.0.0"
88
},

0 commit comments

Comments
 (0)