Skip to content

Commit f5ed969

Browse files
committed
- Fixing readme
1 parent 0f10589 commit f5ed969

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

README.md

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
## Why?
1212
- Frontend ❤️ OpenAPI, but we do not want to use JAVA codegen in our builds
13-
- Quick, lightweight, robust and framework agnostic
13+
- Quick, lightweight, robust and framework agnostic 🚀
1414
- Supports generation of TypeScript clients
1515
- Supports generations of fetch and XHR http clients
1616
- Supports OpenAPI specification v2.0 and v3.0
@@ -20,12 +20,10 @@
2020

2121

2222
## Babel support:
23-
- If you use enums inside your models / definitions then those enums are by default
24-
inside a namespace with the same name as your model. This is called declaration
25-
merging. However, the @babel/plugin-transform-typescript does not support these
26-
namespaces, so if you are using babel in your project please use the `--useUnionTypes`
27-
flag to generate union types instead of traditional enums. More info can be found
28-
here: [Enums vs. Union Types](#enums-vs-union-types).
23+
If you use enums inside your models / definitions then those enums are by default inside a namespace with the same name
24+
as your model. This is called declaration merging. However, the [@babel/plugin-transform-typescript](https://babeljs.io/docs/en/babel-plugin-transform-typescript)
25+
does not support these namespaces, so if you are using babel in your project please use the `--useUnionTypes` flag
26+
to generate union types instead of traditional enums. More info can be found here: [Enums vs. Union Types](#enums-vs-union-types---useuniontypes).
2927

3028

3129
## Install
@@ -72,7 +70,7 @@ $ openapi --help
7270
}
7371
```
7472

75-
**Command line**
73+
**NPX**
7674

7775
```
7876
npx openapi-typescript-codegen --input ./spec.json --output ./dist
@@ -87,17 +85,10 @@ OpenAPI.generate({
8785
input: './spec.json',
8886
output: './dist'
8987
});
90-
```
91-
92-
Or by providing the JSON directly:
93-
94-
```javascript
95-
const OpenAPI = require('openapi-typescript-codegen');
96-
97-
const spec = require('./spec.json');
9888

89+
// Or by providing the content of the spec directly 🚀
9990
OpenAPI.generate({
100-
input: spec,
91+
input: require('./spec.json'),
10192
output: './dist'
10293
});
10394
```
@@ -142,10 +133,9 @@ createUser({
142133
The OpenAPI spec allows you to define [enums](https://swagger.io/docs/specification/data-models/enums/) inside the
143134
data model. By default, we convert these enums definitions to [TypeScript enums](https://www.typescriptlang.org/docs/handbook/enums.html).
144135
However, these enums are merged inside the namespace of the model, this is unsupported by Babel, [see docs](https://babeljs.io/docs/en/babel-plugin-transform-typescript#impartial-namespace-support).
145-
146-
Because we also want to support projects that use Babel [@babel/plugin-transform-typescript](https://babeljs.io/docs/en/babel-plugin-transform-typescript), we offer the flag `--useOptions` to generate
147-
[union types](https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#union-types) instead of
148-
the traditional enums. The difference can be seen below:
136+
Because we also want to support projects that use Babel [@babel/plugin-transform-typescript](https://babeljs.io/docs/en/babel-plugin-transform-typescript),
137+
we offer the flag `--useOptions` to generate [union types](https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#union-types)
138+
instead of the traditional enums. The difference can be seen below:
149139

150140
**Enums:**
151141
```typescript

0 commit comments

Comments
 (0)