Skip to content

Commit d87fd3a

Browse files
committed
📝 Update README.md
1 parent 3e046a9 commit d87fd3a

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

README.md

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,53 @@ npm i -g @nkmr-jp/api-to-go
99
```
1010

1111
# Usage
12-
add config file `.api-to-go.yml`.
13-
```yaml
12+
```sh
13+
$ api-to-go --help
14+
Usage: api-to-go [options] <url> [body]
15+
16+
Convert REST API's JSON payload to Golang struct.
17+
18+
Arguments:
19+
url URL (required)
20+
body HTTP request body. specify by json string or file(json|yml).
21+
22+
Options:
23+
-v, --version output the current version
24+
-H, --headers <string> http request headers. specify by json string or file(json|yml).
25+
-X, --method <string> specify request method to use.
26+
--config <string> location of client config files. (default: "./.api-to-go.yml")
27+
-D, --debug enable debug mode
28+
-h, --help display help for command
29+
```
30+
31+
32+
# Quick Start
33+
34+
Add config file `.api-to-go.yml`.
35+
```yml
1436
api.github.com:
37+
docs:
38+
- https://docs.github.com/en/rest
1539
format:
1640
- /users/{user}
1741
- /users/{user}/repos
1842
```
19-
run command.
43+
44+
Run command.
2045
```sh
2146
cd [your project dir]
2247
api-to-go https://api.github.com/users/github/repos
23-
# > format: /users/{user}/repos
24-
# > generated: api.github.com/users/user/repos.go
25-
# > saved: api.github.com/users/user/repos_sample.json
48+
# > Status: 200 OK
49+
# > Request: GET https://api.github.com/users/github/repos
50+
# > Format: /users/{user}/repos
51+
# > Docs: https://docs.github.com/en/rest
52+
53+
# > Response Body:
54+
# > - api.github.com/users/user/repos.go:1
55+
# > - api.github.com/users/user/repos.json:1
2656
```
27-
check generated files and directories.
57+
58+
Generated files and directories.
2859
```sh
2960
tree -a .
3061
# > .
@@ -33,9 +64,10 @@ check generated files and directories.
3364
# > └── users
3465
# > └── user
3566
# > ├── repos.go
36-
# > └── repos_sample.json
67+
# > └── repos.json
3768
```
38-
check generated struct file `./api.github.com/users/user/repos.go`.
69+
70+
Generated struct file `./api.github.com/users/user/repos.go`.
3971
```go
4072
package user
4173

0 commit comments

Comments
 (0)