|
1 |
| -# OpenAPI Typescript Codegen |
2 |
| - |
3 |
| -[![NPM][npm-image]][npm-url] |
4 |
| -[![License][license-image]][license-url] |
5 |
| -[![Coverage][coverage-image]][coverage-url] |
6 |
| -[![Quality][quality-image]][quality-url] |
7 |
| -[![Code Climate][climate-image]][climate-url] |
8 |
| -[![Downloads][downloads-image]][downloads-url] |
9 |
| -[![Build][build-image]][build-url] |
10 |
| - |
11 |
| -> Node.js library that generates Typescript clients based on the OpenAPI specification. |
12 |
| -
|
13 |
| -## Why? |
14 |
| -- Frontend ❤️ OpenAPI, but we do not want to use JAVA codegen in our builds |
15 |
| -- Quick, lightweight, robust and framework-agnostic 🚀 |
16 |
| -- Supports generation of TypeScript clients |
17 |
| -- Supports generations of Fetch, [Node-Fetch](#node-fetch-support), [Axios](#axios-support), [Angular](#angular-support) and XHR http clients |
18 |
| -- Supports OpenAPI specification v2.0 and v3.0 |
19 |
| -- Supports JSON and YAML files for input |
20 |
| -- Supports generation through CLI, Node.js and NPX |
21 |
| -- Supports tsc and @babel/plugin-transform-typescript |
22 |
| -- Supports aborting of requests (cancelable promise pattern) |
23 |
| -- Supports external references using [json-schema-ref-parser](https://github.com/APIDevTools/json-schema-ref-parser/) |
| 1 | +# Custom Saddleback OpenAPI Typescript Codegen |
| 2 | + |
| 3 | +> For original usage read - [original README](docs/original-readme.md) |
24 | 4 |
|
25 | 5 | ## Install
|
26 | 6 |
|
27 | 7 | ```
|
28 |
| -npm install openapi-typescript-codegen --save-dev |
| 8 | +npm install saddleback-openapi-typescript-codegen --save-dev |
29 | 9 | ```
|
30 | 10 |
|
| 11 | +## Step-by-step guide based on ME app |
| 12 | +### auto fetch |
| 13 | +1. install the package |
| 14 | +2. create config files for every microservice that you need (put it in the root project folder for example openapiEvents.config.json) |
| 15 | +3. inside the config file you need to specify |
| 16 | + 1. output folder (for Events it would be ./src/shared/api/events) |
| 17 | + 2. microservice that you're specifying ("Events") |
| 18 | + 3. environment that using for fetch ("feature") |
| 19 | + 4. if you don't want to generate whole microservices, you can specify filterMethod and filterArray |
| 20 | +4. create utility files that used in services |
| 21 | + 1. 'baseAxios' should export axios instance that be used for fetch |
| 22 | + 2. 'getBaseConfig' and 'serviceError' described here https://github.com/saddlebackdev/church-management/wiki/Services |
| 23 | +5. run the command where you should pass your login and pass from saddleback identity server `saddlebackApi --config openapiEvents.config.json --login login --password password` |
| 24 | +### local swagger |
| 25 | +1. same as above |
| 26 | +2. same as above |
| 27 | +3. addition specify the input path to the swagger.json file |
| 28 | +4. same as above |
| 29 | +5. run the command `saddlebackApi --config openapiEvents.config.json` |
| 30 | + |
31 | 31 | ## Usage
|
32 | 32 |
|
| 33 | +Generated folders should be untouchable. Because every generate action will delete and put generated files into the output folder. |
| 34 | + |
33 | 35 | ```
|
34 |
| -$ openapi --help |
| 36 | +$ saddlebackOpenapi --help |
35 | 37 |
|
36 |
| - Usage: openapi [options] |
| 38 | + Usage: saddlebackOpenapi [options] |
37 | 39 |
|
38 | 40 | Options:
|
39 | 41 | -V, --version output the version number
|
40 |
| - -i, --input <value> OpenAPI specification, can be a path, url or string content (required) |
41 |
| - -o, --output <value> Output directory (required) |
42 |
| - -c, --client <value> HTTP client to generate [fetch, xhr, node, axios, angular] (default: "fetch") |
43 |
| - --name <value> Custom client class name |
44 |
| - --useOptions Use options instead of arguments |
45 |
| - --useUnionTypes Use union types instead of enums |
46 |
| - --exportCore <value> Write core files to disk (default: true) |
47 |
| - --exportServices <value> Write services to disk (default: true) |
48 |
| - --exportModels <value> Write models to disk (default: true) |
49 |
| - --exportSchemas <value> Write schemas to disk (default: false) |
50 |
| - --indent <value> Indentation options [4, 2, tab] (default: "4") |
51 |
| - --postfix <value> Service name postfix (default: "Service") |
52 |
| - --request <value> Path to custom request file |
| 42 | + -i, --input <value> OpenAPI specification, can be a path, url or string content |
| 43 | + -o, --output <value> Output directory should end with service name workflows | events | notifications | core | journey | giving | smallGroup |
| 44 | + -c, --config <value> Path to the config file |
| 45 | + -l, --login <value> Login |
| 46 | + -p, --password <value> Password |
| 47 | + -e, --environment <value> Environment dev | stage | stage2 |
| 48 | + -s, --service <value> Service Service Workflows | Events | Notifications | Core | Journey | Giving | SmallGroup |
53 | 49 | -h, --help display help for command
|
| 50 | + -m, --filterMethod Filter method include(default) | exclude') |
| 51 | + -f, --filterArray Filter array |
54 | 52 |
|
55 | 53 | Examples
|
56 |
| - $ openapi --input ./spec.json --output ./generated |
57 |
| - $ openapi --input ./spec.json --output ./generated --client xhr |
| 54 | + $ saddlebackOpenApi --input ./spec.json --output ./generated |
| 55 | + $ saddlebackOpenApi --config ./openapi.config.json |
| 56 | + $ saddlebackOpenApi -o "./folderPath" -l "Login" -p "Password" -e "dev" -s "core" |
| 57 | +``` |
| 58 | + |
| 59 | +## Config file |
| 60 | +*extends original OPTIONS* |
| 61 | +``` |
| 62 | + input required in the config or cmd arguments |
| 63 | + output required in the config or cmd arguments |
| 64 | +
|
| 65 | + additionalModelFileExtension optional |
| 66 | + additionalServiceFileExtension optional |
| 67 | + removeLodashPrefixes optional |
58 | 68 | ```
|
| 69 | +### Settings: |
| 70 | +### `input` |
| 71 | +- Default: `undefined` |
| 72 | +- Type: `string` |
| 73 | + |
| 74 | +OpenAPI specification, can be a path, url or string content (required in the config or cmd arguments) |
| 75 | + |
| 76 | +### `output` |
| 77 | +- Default: `undefined` |
| 78 | +- Type: `string` |
| 79 | + |
| 80 | +Output directory (required in the config or cmd arguments) |
| 81 | + |
| 82 | +### `login` (autofetch) |
| 83 | +- Default: `undefined` |
| 84 | +- Type: `string` |
| 85 | + |
| 86 | +Login to saddleback identity server |
| 87 | + |
| 88 | +### `password` (autofetch) |
| 89 | +- Default: `undefined` |
| 90 | +- Type: `string` |
| 91 | + |
| 92 | +Password to saddleback identity server |
| 93 | + |
| 94 | +### `environment` (autofetch) |
| 95 | +- Default: `undefined` |
| 96 | +- Type: `'dev' | 'stage' | 'stage2'` |
| 97 | + |
| 98 | +Which Environment should be used for swagger.json |
| 99 | + |
| 100 | +### `service` (autofetch) |
| 101 | +- Default: `undefined` |
| 102 | +- Type: `'workflows' | 'event' | 'notifications' | 'core'` |
| 103 | + |
| 104 | +Which service should be fetched |
| 105 | + |
| 106 | +### `filterMethod` (autofetch) |
| 107 | +- Default: `include` |
| 108 | +- Type: `'include' | 'exclude'` |
| 109 | + |
| 110 | +Which method of sort should be applied to the filter array |
| 111 | + |
| 112 | +### `filterArray` (autofetch) |
| 113 | +- Default: `undefined` |
| 114 | +- Type: `string[]` |
| 115 | + |
| 116 | +Which services should be *included* or *excluded* to/from generated list |
| 117 | + |
| 118 | +### `additionalModelFileExtension` |
| 119 | +- Default: `true` |
| 120 | +- Type: `boolean` |
| 121 | + |
| 122 | +Apply `*.models.*` extension to model files. |
| 123 | + |
| 124 | +For example (myModel.ts -> myModel.models.ts) |
| 125 | + |
| 126 | +### `additionalServiceFileExtension` |
| 127 | +- Default: `true` |
| 128 | +- Type: `boolean` |
| 129 | + |
| 130 | +Apply `*.service.*` extension to service files. |
| 131 | + |
| 132 | +For example (myService.ts -> myService.service.ts) |
| 133 | + |
| 134 | +### `removeLodashPrefixes` |
| 135 | +- Default: `true` |
| 136 | +- Type: `boolean` |
| 137 | + |
| 138 | +Remove special prefixes that are separated by `_` at the start of names. |
59 | 139 |
|
60 |
| -Documentation |
61 |
| -=== |
62 |
| -- [Basic usage](docs/basic-usage.md) |
63 |
| -- [OpenAPI object](docs/openapi-object.md) |
64 |
| -- [Client instances](docs/client-instances.md) `--name` |
65 |
| -- [Argument vs. Object style](docs/arguments-vs-object-style.md) `--useOptions` |
66 |
| -- [Enums vs. Union types](docs/enum-vs-union-types.md) `--useUnionTypes` |
67 |
| -- [Runtime schemas](docs/runtime-schemas.md) `--exportSchemas` |
68 |
| -- [Enum with custom names and descriptions](docs/custom-enums.md) |
69 |
| -- [Nullable props (OpenAPI v2)](docs/nullable-props.md) |
70 |
| -- [Authorization](docs/authorization.md) |
71 |
| -- [External references](docs/external-references.md) |
72 |
| -- [Canceling requests](docs/canceling-requests.md) |
73 |
| -- [Custom request file](docs/custom-request-file.md) |
74 |
| - |
75 |
| -Support |
76 |
| -=== |
77 |
| -- [Babel support](docs/babel-support.md) |
78 |
| -- [Axios support](docs/axios-support.md) |
79 |
| -- [Angular support](docs/angular-support.md) |
80 |
| -- [Node-Fetch support](docs/node-fetch-support.md) |
81 |
| - |
82 |
| -[npm-url]: https://npmjs.org/package/openapi-typescript-codegen |
83 |
| -[npm-image]: https://img.shields.io/npm/v/openapi-typescript-codegen.svg |
84 |
| -[license-url]: LICENSE |
85 |
| -[license-image]: http://img.shields.io/npm/l/openapi-typescript-codegen.svg |
86 |
| -[coverage-url]: https://codecov.io/gh/ferdikoomen/openapi-typescript-codegen |
87 |
| -[coverage-image]: https://img.shields.io/codecov/c/github/ferdikoomen/openapi-typescript-codegen.svg |
88 |
| -[quality-url]: https://lgtm.com/projects/g/ferdikoomen/openapi-typescript-codegen |
89 |
| -[quality-image]: https://img.shields.io/lgtm/grade/javascript/g/ferdikoomen/openapi-typescript-codegen.svg |
90 |
| -[climate-url]: https://codeclimate.com/github/ferdikoomen/openapi-typescript-codegen |
91 |
| -[climate-image]: https://img.shields.io/codeclimate/maintainability/ferdikoomen/openapi-typescript-codegen.svg |
92 |
| -[downloads-url]: http://npm-stat.com/charts.html?package=openapi-typescript-codegen |
93 |
| -[downloads-image]: http://img.shields.io/npm/dm/openapi-typescript-codegen.svg |
94 |
| -[build-url]: https://circleci.com/gh/ferdikoomen/openapi-typescript-codegen/tree/master |
95 |
| -[build-image]: https://circleci.com/gh/ferdikoomen/openapi-typescript-codegen/tree/master.svg?style=svg |
| 140 | +For example (Custom_Prefix_Name -> Name) |
0 commit comments