the-pawn-2017 / r5t

Your OpenAPI 3 documentation is automatically generated via Go code, without relying on comments
GNU Lesser General Public License v3.0
1 stars 0 forks source link
api-documentation go golang oauth2 openapi3 rest-api swagger-ui

r5t

It is a new implementation based on go-openapi

install: go get -u github.com/the-pawn-2017/r5t

CAREFULLY USE IT IN YOUR PROJECT, BECAUSE IT IN DEVELOPING

I am currently testing with my own projects to refine R5T, expecting it to stabilize by the end of August. At that point, I will mark R5T as ready for official use, making it convenient for everyone.

why create this repo?

  1. I would like to implement more other features, such as support for GIN and ECHO.
  2. Since many of my projects after that require REST API documentation, I'm more motivated to maintain it.

    version

    v0.3

    todo

    • [x] all components support and limit
    • [x] param config, but no example and limit
    • [x] Registering res&req model,now,it can use json,form, others type in developing.
    • [x] Supporting OAuth2 , only code and implicit
    • [x] register model
    • [ ] complete test
    • [ ] full document for this repo
    • [x] Support other web server,now,echo can use r5t by some function, it's in example/echo

some useful feature

  1. fast pagination
  2. easy to use for OAuth2
  3. concise and powerful API, like Reqjson,ResJson,ResString.
  4. Cusom req and res can could work in some special cases.

    example:

    go /test/spec_test view some example

    type Test struct {
    A string
    B string `validate:"required"`
    }
    s := spec.NewSpec()
    s.Security(
        security.WithOAuth2Code("ziteal", "http://10.45.8.189:8080/oauth/v2/authorize", "http://10.45.8.189:8080/oauth/v2/token",
            security.AddScope("openid", "OPENID IS USING FOR ID")),
    )
    // than, you can use OAuth2 code mode now
    s.Post("/gkd").NeedSecurify("ziteal", []string{"openid"}).
        ReqJSON(model.ModelOf[Test](), req.WithExample(Test{A: "A", B: "B"})).
        ResJSON(http.StatusOK, model.ModelOf[Test](), res.WithExample(Test{A: "A", B: "B"}))

    tools

    swagger-ui-edit

    inspired by a-h/rest