@povio/openapi-codegen-cli 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -0
- package/dist/sh.js +201 -0
- package/package.json +72 -0
- package/src/generators/templates/endpoints.hbs +35 -0
- package/src/generators/templates/models.hbs +20 -0
- package/src/generators/templates/partials/endpoint-config.hbs +18 -0
- package/src/generators/templates/partials/endpoint-params.hbs +1 -0
- package/src/generators/templates/partials/import.hbs +1 -0
- package/src/generators/templates/partials/query-keys.hbs +5 -0
- package/src/generators/templates/partials/query-use-mutation.hbs +5 -0
- package/src/generators/templates/partials/query-use-query.hbs +6 -0
- package/src/generators/templates/queries.hbs +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# OpenAPI code generation CLI
|
|
2
|
+
|
|
3
|
+
**NOTE:** This CLI tool is specifically designed for custom usage within our organization. The generated code output is in alignment with our internal templates.
|
|
4
|
+
|
|
5
|
+
Use this tool to generate code (Zod schemas, API definitions and React queries) from OpenAPI v3 specification. API definitions are customized to fit the REST client wrapper used in our Next.js template. React queries are generated in alignment with our code standards, without the need for explicit types.
|
|
6
|
+
|
|
7
|
+
The tool partially leverages code from [openapi-zod-client](https://github.com/astahmer/openapi-zod-client) repository.
|
|
8
|
+
|
|
9
|
+
## Setup
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
yarn add @poviolabs/openapi-codegen-cli
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn openapi-codegen generate --input http://localhost:3001/docs-json
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Options
|
|
22
|
+
|
|
23
|
+
### Generate command
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
--input <path> Path/url to OpenAPI/Swagger document as json/yaml
|
|
27
|
+
--output <path> Output path (default: 'output')
|
|
28
|
+
--includeNamespaces Include namespaces inside generated files (default: true)
|
|
29
|
+
--splitByTags Split output into directories based on tags in OpenAPI operations (default: true)
|
|
30
|
+
--defaultTag Default tag name for code shared accross multiple tags (default: 'Common')
|
|
31
|
+
--excludeTags Comma separated list of tags excluded from the output
|
|
32
|
+
--prettier Run prettier command on output after code generation (default: true)
|
|
33
|
+
--verbose Show log messages during execution
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Development
|
|
37
|
+
|
|
38
|
+
### Test locally
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# prerequisites
|
|
42
|
+
corepack install
|
|
43
|
+
yarn
|
|
44
|
+
|
|
45
|
+
# run tests
|
|
46
|
+
yarn test
|
|
47
|
+
|
|
48
|
+
# run sources with tsx
|
|
49
|
+
yarn start --help
|
|
50
|
+
yarn start generate --input ./test/baby-jira.json --verbose
|
|
51
|
+
|
|
52
|
+
# build new version
|
|
53
|
+
yarn build
|
|
54
|
+
|
|
55
|
+
# test build
|
|
56
|
+
yarn start --help
|
|
57
|
+
yarn start:dist generate --input ./test/baby-jira.json --verbose
|
|
58
|
+
```
|