-
-
Notifications
You must be signed in to change notification settings - Fork 11
How to use
First download the cli binary on our release page, and unzip the binary to some place in your PATH
.
Then, you should create a yaml file to describe your API.
Take the minimal "student" API as an example:
database:
tablename: student
fields:
- name: name
type: varchar(24)
- name: birthday
type: date
- name: school_id
type: int
Save this file as ./student.yaml
and then run:
./autoAPI -f ./student.yaml -o ./student
And there's the Golang HTTP API code is waiting for you under ./student
, it's just a normal Golang project, you can use go build
to get its binary, use go run ./main.go
to run it, or use your favorite editor to do some changes.
Note the generated API assume that there's a environment variable DB_ADDRESS
to specify the database address to connect to.
You can add more fields into the config file and get different APIs. View our config document for more infomation.
Basically, since autoAPI is also released as a Docker image, you can use it directly as a step in GitHub Actions:
- name: Build code
uses: docker://shureeducation/auto-api:v1.0
with:
args: -f ./student.yaml -o ./student
You can see this example.