Giter VIP home page Giter VIP logo

autoapi's Introduction

autoAPI

Tests FOSSA Status

Create an CRUD API server directly from a table in database or a yaml file.

Things we'll never ever ever ever ever support

DBMS

  • Oracle

Language

  • Java (CAUSE IT IS THE WORST LANGUAGE IN THIS UNIVERSE!!!)

License

FOSSA Status

autoapi's People

Contributors

fossabot avatar longfangsong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

autoapi's Issues

提供默认的 Docker 镜像版本号

现在 Docker 镜像的版本号只支持手动指定。最好能自动确定。

Describe the solution you'd like
按顺序检查:

  • 手动在 yaml 中指定
  • 根据环境变量 $DOCKER_TAG 确定(若存在)
  • 根据环境变量ci-v${GITHUB_RUN_NUMBER}确定(若 $GITHUB_RUN_NUMBER 存在)

Add CI

Use GitHub Actions as our CI.
The CI should build binary files for all three major platforms.

功能测试

目前计划要写的第一个测试是功能测试,测试流程如下:

  • 给定一个yaml
  • 生成对应API
  • build起API的docker镜像
  • run起这个docker镜像
  • 检测各个API是否可以正常访问

仍待解决的问题是在测试环境起一个pgsql可能会存在困难。

  • 冒烟测试
  • 基本CRUD API测试
  • 复杂查询测试
  • 从数据库推断表结构测试
  • 从DDL推断表结构测试

Generate k8s deployment yaml

eg.

k8s:
  db: "postgres://xxx@shu-student-postgres-svc:5432/shu-student?sslmode=disable"

Should generate:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: shu-student
spec:
  selector:
    matchLabels:
      run: shu-student
  replicas: 1
  template:
    metadata:
      labels:
        run: shu-student
    spec:
      containers:
      - name: shu-student
        image: xxx/shu-student:138153507
        livenessProbe:
          httpGet:
            path: /ping
            port: 8000
          initialDelaySeconds: 5
          periodSeconds: 5
        env:
        - name: DB_ADDRESS
          value: "postgres://xxx@shu-student-postgres-svc:5432/shu-student?sslmode=disable"
        ports:
        - containerPort: 8000
---
apiVersion: v1
kind: Service
metadata:
  name: shu-student-svc
spec:
  selector:
     run: shu-student
  ports:
  - protocol: TCP
    port: 8000
    targetPort: 8000

And if no k8s entry exists, nothing should be generated.

CLI flags

Maybe we need a --force flag for our cli tool to control if rm -rf output before generate.
And a -h / --help for displaying usage.

从DDL推断表结构测试

Describe the solution you'd like
添加从DDL推断表结构的测试

Additional context
可以在 #56 找到添加功能测试的方法。

Support complex queries

Add a complex field in yaml and let the user specify SQL and return values by an api.
eg.

complex:
    sql: "select aaa, bbb from ccc, ddd where eee = fff and ggg = $1 or hhh = $2;"
    parmas:
      - name: "iii"
        type: int
      - name: "jjj"
        type: string
    result:
      name: "mmm"
      array: true
      page: true
      fields:
        - name: "kkk"
          type: string
        - name: "lll"
          type: int64

Will generate an api endpoint like

/table/mmm?iii=1&jjj=qwerty&limit=10&offset=10

从数据库推断表结构测试

Describe the solution you'd like
添加从数据库推断表结构的测试。

Additional context
可以在 #56 找到添加功能测试的方法。

基于 ssh 的 CD 配置

目前生成的 GitHub Action 不包含CD功能,在完成 #9 之后,考虑支持 ssh 到目标服务器 apply 生成的yaml。

Describe the solution you'd like

使用 GHAction market 中的某个 ssh 库执行 ssh,apply生成的yaml

Refactor

这屑代码丑的一匹
让爷给他重构了

一些重构的点:

  • 为工具数据结构WithCase实现 Marshaler 等接口,以便直接从 yaml parse 出来
  • 修改yaml结构,使其更容易 parse
  • 直接 parse yaml 得到各种数据结构,不再经过各种 compat,即让yamlFile继承/组合自table等
  • 更合理的文件夹组织和层次分割

生成并发布 Docker 镜像

目前发布的CI中并不包含生成Docker镜像的代码

Describe the solution you'd like
生成Docker镜像,并推送到Dockerhub。

Parse YAML

Get Table name and fields info from yaml files

更多用例

Describe the solution you'd like
创建更多不同的例子。
目前的例子需要启动数据库才能运行(为了检查从数据库中拿元数据是否成功),但这对开发者的环境搭建提出了一定要求,即使对非相关功能的改动也需要起这个数据库,显得很蠢。

考虑:

  • 提供多组不同的例子,根据开发者的需要运行相应例子即可
  • 正确性由一组覆盖所有功能的测试保证
  • 也可直接在开发时运行测试,只有运行部分测试时才需要开启数据库,在更改的代码不涉及元数据时开发者可以不运行这些测试

Additional context
其他方案:

  • 提供一个预先搭建好数据库环境的Docker
    这个做起来并不比写测试容易,而且Docker这个东西在**推推拉拉一万年😭

Blocked by #11.

Add cli

Make it usable from command line!

其他类型的id

Describe the solution you'd like
目前id类型固定为整数,但实际上对于部分场景(学生证号),id类型可以是字符串等,故可以考虑去掉这个限制。

支持多种配置文件类型

Describe the solution you'd like
除了已经支持的 yaml 还支持

  • toml
  • json

Additional context
不考虑支持xml,xml用来写配置文件是垃圾

生成压缩过的 release 包

目前生成 release 的CI有如下缺点:

  • 生成的文件名是 autoAPI-(操作系统名)-amd64(扩展名),但是用户应该希望使用的二进制文件名是 autoAPI(扩展名)
  • 没压缩过,在**的网络环境下可能会显著增加下载时间

Describe the solution you'd like
生成 autoAPI-(操作系统名)-amd64.zip,内含对应平台的二进制文件,其名称为 autoAPI(扩展名)

https://github.com/marketplace/actions/go-cross-build might help.

Port into browser via wasm

Describe the solution you'd like
将 go 编译到wasm,使得这一项目可以在浏览器中使用

把报告写一下

没空写代码可以把报告写一下。

最好可以搞一个生成报告的template.

Linting support

Describe the solution you'd like

As @laojianzi suggested,引入一个linting tool。

Additional context
不知道会不会提高开发者的门槛……希望不会吧

Make generating GitHub actions configuable

Currently, no matter whether it is necessary, a Github Actions file will be generated.
But sometimes we don't need this, eg. in a repo which is full of yamls and use Github Actions itself to generate several docker images together.

So generating things like Github Actions files should be configuable.
eg.

githubactions: false

And it should has a default value true.

Web GUI

Though most developer enjoy using things from CLI. There might be some users want to use a GUI.

So create a web GUI for this project might be useful.

Java Backend Support

Describe the solution you'd like
WE NEED JAVA!

Additional context
#JAVA LIVES MATTER

复杂查询的 param 支持多种类型

现在只支持 string 兼容类型

Describe the solution you'd like
在 handler 的模版里面支持各种类型的互相转化。
比如对整数类型就生成一个

{%v param.Name.CamelCase() %}Str := mux.Vars(r)["{%v param.Name.SnakeCase() %}"]
{%v param.Name.CamelCase() %}, err := strconv.ParseInt({%v param.Name.CamelCase() %}Str, 10, 64)

文件末尾自动添加换行

Describe the solution you'd like
所有文件是否需要统一,最后需要一行换行。

Additional context
Github review时能看到非常多的最后没有换行。

复杂查询测试

Describe the solution you'd like
添加对复杂查询的测试。

Additional context
可以在 #56 找到添加功能测试的方法。

支持作为 GitHub actions 使用

Describe the solution you'd like
在根目录下加一个 actions.yml(可能需要配合相关的Dockerfile等等), 使得该项目可以直接作为 GitHub action 的一个step使用

分页控制

Describe the solution you'd like
有一个flag来控制是否分页

使用说明书

Describe the solution you'd like
编写详细的使用说明书:

  • 如何作为cli使用
  • 如何作为 GitHub Actions 的一个单元使用
  • config的来源和所有可配置项

Plan

yaml examples:
Naive table:

dbengin: pgsql
tablename: test
fields:
  - name: id
    type: int
  - name: name
    type: string

Auto decide everything it can from meta tables

dbengin: pgsql
tablename: test

自动生成外键上的关联查询

目前外键上的关联查询也要用户给我们sql才能生成,但外键上的关联查询还是很常见的,最好不要让用户提供sql
Describe the solution you'd like
让用户给出(或者查元表查出)外键对面的表的信息,自动生成相关api

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.