Skip to content

Commit 6c87ad4

Browse files
authored
Merge pull request #64 from nicolas-chaulet/fix/bin-command
fix(bin): rename openapi command to openapi-ts
2 parents c557d0e + cef2f96 commit 6c87ad4

File tree

6 files changed

+19
-23
lines changed

6 files changed

+19
-23
lines changed

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ yarn add @nicolas-chaulet/openapi-typescript-codegen -D
4040
## Usage
4141

4242
```
43-
$ openapi --help
43+
$ openapi-ts --help
4444
45-
Usage: openapi [options]
45+
Usage: openapi-ts [options]
4646
4747
Options:
4848
-V, --version output the version number
@@ -64,18 +64,14 @@ $ openapi --help
6464
--request <value> Path to custom request file
6565
--useDateType <value> Output Date instead of string for the format "date-time" in the models (default: false)
6666
-h, --help display help for command
67-
68-
Examples
69-
$ openapi --input ./spec.json --output ./generated
70-
$ openapi --input ./spec.json --output ./generated --client xhr
7167
```
7268

7369
## Formatting
7470

7571
By default, your client will be automatically formatted according to your configuration. To disable automatic formatting, run
7672

7773
```sh
78-
openapi -i path/to/openapi.json -o src/client --no-autoformat
74+
openapi-ts -i path/to/openapi.json -o src/client --no-autoformat
7975
```
8076

8177
You can also prevent your client from being processed by formatters and linters by adding your output path to the tool's ignore file (e.g. `.eslintignore`, `.prettierignore`).
@@ -85,7 +81,7 @@ You can also prevent your client from being processed by formatters and linters
8581
We do not generate TypeScript [enums](https://www.typescriptlang.org/docs/handbook/enums.html) because they are not standard JavaScript and pose [typing challenges](https://dev.to/ivanzm123/dont-use-enums-in-typescript-they-are-very-dangerous-57bh). If you want to iterate through possible field values without manually typing arrays, you can export enums by running
8682

8783
```sh
88-
openapi -i path/to/openapi.json -o src/client --enums
84+
openapi-ts -i path/to/openapi.json -o src/client --enums
8985
```
9086

9187
This will export your enums as plain JavaScript objects. For example, `Foo` will generate the following

bin/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
'use strict';
44

5-
const path = require('path');
5+
const Path = require('path');
66
const { program } = require('commander');
7-
const pkg = require('../package.json');
7+
const json = require('../package.json');
88

99
const params = program
10-
.name('openapi')
10+
.name(Object.keys(json.bin)[0])
1111
.usage('[options]')
12-
.version(pkg.version)
12+
.version(json.version)
1313
.requiredOption('-i, --input <value>', 'OpenAPI specification, can be a path, url or string content (required)')
1414
.requiredOption('-o, --output <value>', 'Output directory (required)')
1515
.option('-c, --client <value>', 'HTTP client to generate [fetch, xhr, node, axios, angular]', 'fetch')
@@ -32,7 +32,7 @@ const params = program
3232
.parse(process.argv)
3333
.opts();
3434

35-
const OpenAPI = require(path.resolve(__dirname, '../dist/index.js'));
35+
const OpenAPI = require(Path.resolve(__dirname, '../dist/index.js'));
3636

3737
const parseBooleanOrString = value => (value === true || value === 'true' ? true : value);
3838

bin/index.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('bin', () => {
9494

9595
it('it should display help', async () => {
9696
const result = sync('node', ['./bin/index.js', '--help', '--no-write']);
97-
expect(result.stdout.toString()).toContain(`Usage: openapi [options]`);
97+
expect(result.stdout.toString()).toContain(`Usage: openapi-ts [options]`);
9898
expect(result.stdout.toString()).toContain(`-i, --input <value>`);
9999
expect(result.stdout.toString()).toContain(`-o, --output <value>`);
100100
expect(result.stderr.toString()).toBe('');

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"version": "0.27.28",
44
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
55
"author": "Ferdi Koomen",
6-
"homepage": "https://github.com/CanoaPBC/openapi-typescript-codegen",
6+
"homepage": "https://github.com/nicolas-chaulet/openapi-typescript-codegen/",
77
"repository": {
88
"type": "git",
9-
"url": "git+https://github.com/CanoaPBC/openapi-typescript-codegen.git"
9+
"url": "git+https://github.com/nicolas-chaulet/openapi-typescript-codegen.git"
1010
},
1111
"bugs": {
12-
"url": "https://github.com/ferdikoomen/openapi-typescript-codegen/issues"
12+
"url": "https://github.com/nicolas-chaulet/openapi-typescript-codegen/issues"
1313
},
1414
"license": "MIT",
1515
"keywords": [
@@ -34,7 +34,7 @@
3434
"main": "dist/index.js",
3535
"types": "types/index.d.ts",
3636
"bin": {
37-
"openapi": "bin/index.js"
37+
"openapi-ts": "bin/index.js"
3838
},
3939
"files": [
4040
"bin/index.js",

src/openApi/v3/interfaces/OpenApi.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import type { OpenApiTag } from './OpenApiTag';
1010
* https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md
1111
*/
1212
export interface OpenApi {
13-
openapi: string;
13+
components?: OpenApiComponents;
14+
externalDocs?: OpenApiExternalDocs;
1415
info: OpenApiInfo;
15-
servers?: OpenApiServer[];
16+
openapi: string;
1617
paths: OpenApiPaths;
17-
components?: OpenApiComponents;
1818
security?: OpenApiSecurityRequirement[];
19+
servers?: OpenApiServer[];
1920
tags?: OpenApiTag[];
20-
externalDocs?: OpenApiExternalDocs;
2121
}

0 commit comments

Comments
 (0)