Skip to content

Commit 082f664

Browse files
committed
chore: improve Docs
1 parent 6d28473 commit 082f664

File tree

2 files changed

+10
-58
lines changed

2 files changed

+10
-58
lines changed

README.md

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- Quick, lightweight, robust and framework-agnostic 🚀
1616
- Supports generation of TypeScript clients
1717
- Supports generations of [Axios](#axios-support) client
18-
- Supports OpenAPI specification v2.0 and v3.0
18+
- Supports OpenAPI specification v3.0
1919
- Supports JSON and YAML files for input
2020
- Supports generation through CLI, Node.js and NPX
2121
- Supports tsc and @babel/plugin-transform-typescript
@@ -40,7 +40,7 @@ $ openapi --help
4040
-V, --version output the version number
4141
-i, --input <value> OpenAPI specification, can be a path, url or string content (required)
4242
-o, --output <value> Output directory (required)
43-
-c, --client <value> HTTP client to generate [fetch, xhr, axios, node] (default: "fetch")
43+
-c, --client <value> HTTP client to generate [axios] (default: "axios")
4444
--useOptions Use options instead of arguments
4545
--useUnionTypes Use union types instead of enums
4646
--exportCore <value> Write core files to disk (default: true)
@@ -56,7 +56,7 @@ $ openapi --help
5656
Examples
5757
$ openapi --input ./spec.json
5858
$ openapi --input ./spec.json --output ./dist
59-
$ openapi --input ./spec.json --output ./dist --client xhr
59+
$ openapi --input ./spec.json --output ./dist --client axios
6060
```
6161

6262

@@ -336,34 +336,6 @@ enum EnumWithStrings {
336336
}
337337
```
338338

339-
340-
### Nullable in OpenAPI v2
341-
In the OpenAPI v3 spec you can create properties that can be NULL, by providing a `nullable: true` in your schema.
342-
However, the v2 spec does not allow you to do this. You can use the unofficial `x-nullable` in your specification
343-
to generate nullable properties in OpenApi v2.
344-
345-
```json
346-
{
347-
"ModelWithNullableString": {
348-
"required": ["requiredProp"],
349-
"description": "This is a model with one string property",
350-
"type": "object",
351-
"properties": {
352-
"prop": {
353-
"description": "This is a simple string property",
354-
"type": "string",
355-
"x-nullable": true
356-
},
357-
"requiredProp": {
358-
"description": "This is a simple string property",
359-
"type": "string",
360-
"x-nullable": true
361-
}
362-
}
363-
}
364-
}
365-
```
366-
367339
Generated code:
368340
```typescript
369341
interface ModelWithNullableString {
@@ -372,31 +344,6 @@ interface ModelWithNullableString {
372344
}
373345
```
374346

375-
376-
### Authorization
377-
The OpenAPI generator supports Bearer Token authorization. In order to enable the sending
378-
of tokens in each request you can set the token using the global OpenAPI configuration:
379-
380-
```typescript
381-
import { OpenAPI } from './generated';
382-
383-
OpenAPI.TOKEN = 'some-bearer-token';
384-
```
385-
386-
Alternatively, we also support an async method that provides the token for each request.
387-
You can simply assign this method to the same `TOKEN `property in the global OpenAPI object.
388-
389-
```typescript
390-
import { OpenAPI } from './generated';
391-
392-
const getToken = async () => {
393-
// Some code that requests a token...
394-
return 'SOME_TOKEN';
395-
}
396-
397-
OpenAPI.TOKEN = getToken;
398-
```
399-
400347
### Generate client instance with `--exportClient` option
401348

402349
The OpenAPI generator allows to create client instances to support the multiple backend services use case.
@@ -411,7 +358,7 @@ openapi --input ./spec.json --output ./dist --exportClient true --name DemoAppCl
411358
The generated client will be exported from the `index` file and can be used as shown below:
412359
```typescript
413360
// create the client instance with server and authentication details
414-
const appClient = new DemoAppClient({ base: 'http://server-host.com', token: '1234' });
361+
const appClient = new DemoAppClient({ token: '1234' });
415362

416363
// use the client instance to make the API call
417364
const res: OrganizationResponse = await appClient.organizations.createOrganization({
@@ -420,6 +367,11 @@ const res: OrganizationResponse = await appClient.organizations.createOrganizati
420367
});
421368
```
422369

370+
```typescript
371+
// NODE.JS Only. You can provide AccountSid and AuthToken instead.
372+
const appClient = new DemoAppClient({ accountSid: 'ACXXX', authToken: "1234" });
373+
```
374+
423375
### References
424376

425377
Local references to schema definitions (those beginning with `#/definitions/schemas/`)

bin/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const params = program
1212
.version(pkg.version)
1313
.requiredOption('-i, --input <value>', ' specification, can be a path, url or string content (required)')
1414
.requiredOption('-o, --output <value>', 'Output directory (required)')
15-
.option('-c, --client <value>', 'HTTP client to generate [fetch, xhr, node, axios]', 'fetch')
15+
.option('-c, --client <value>', 'HTTP client to generate [axios]', 'axios')
1616
.option('--useOptions', 'Use options instead of arguments')
1717
.option('--useUnionTypes', 'Use union types instead of enums')
1818
.option('--exportCore <value>', 'Write core files to disk', true)

0 commit comments

Comments
 (0)