这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
10c5999
chore(ktracer/update-dep): update references to point to istreamlabs
ktracer-isp Jul 9, 2020
9c5287b
update go.mod post-"go test"(ktracer/update-dep):
ktracer-isp Jul 9, 2020
c66f5a8
Merge pull request #1 from istreamlabs/ktracer/update-dep
ktracer-isp Jul 9, 2020
f1389fa
renamed file to trigger GitHub Action inclusion
ktracer-isp Jul 10, 2020
8f07c16
Merge branch 'main' into ktracer/update-dep
ktracer-isp Jul 10, 2020
f0cc34f
chore(ktracer/update-dep): move it back
ktracer-isp Jul 10, 2020
67b1f8b
Merge pull request #2 from istreamlabs/ktracer/update-dep
ktracer-isp Jul 10, 2020
98eb248
chore(ktracer/update-dep): update badges, README to point to istreaml…
ktracer-isp Jul 10, 2020
3466810
apisprout is not an istreamlabs tool
ktracer-isp Jul 10, 2020
043d04a
Merge pull request #3 from istreamlabs/ktracer/update-dep
ktracer-isp Jul 10, 2020
847470f
Merge branch 'master' of github.com:danielgtaylor/huma into dt/conten…
danielgtaylor Jul 13, 2020
9528137
Merge branch 'master' of github.com:danielgtaylor/huma into dt/conten…
danielgtaylor Jul 13, 2020
1d51f42
Merge pull request #4 from istreamlabs/dt/content-negotiation
danielgtaylor Jul 13, 2020
2bdcc5f
fix: return correct status to other middleware
danielgtaylor Jul 21, 2020
829cb02
Merge pull request #5 from istreamlabs/dt/writer-status
danielgtaylor Jul 21, 2020
7f17cb0
chore(deps): bump uvicorn from 0.11.3 to 0.11.7 in /benchmark/fastapi
dependabot[bot] Jul 29, 2020
73f9124
fix(ktracer/bp-171-nilvalue): add meaningful error message if param h…
ktracer-isp Jul 29, 2020
1fb6d27
Merge pull request #6 from istreamlabs/dependabot/pip/benchmark/fasta…
ktracer-isp Jul 29, 2020
0c4c65d
chore(ktracer/bp-171-nilvalue): add test
ktracer-isp Jul 30, 2020
fb0e9e1
Merge pull request #7 from istreamlabs/ktracer/BP-171-nilvalue
ktracer-isp Jul 30, 2020
2f343a6
Merge pull request #8 from danielgtaylor/master
danielgtaylor Aug 24, 2020
9c9f11e
chore: code drop merge from upstream
danielgtaylor Sep 30, 2020
f75758d
Merge pull request #9 from istreamlabs/redesign-merge
danielgtaylor Oct 1, 2020
66fb93b
fix: include tags in rendered OpenAPI
danielgtaylor Oct 2, 2020
4bf189f
Merge pull request #10 from istreamlabs/tags-fix
danielgtaylor Oct 23, 2020
51b47ca
fix: better handling of array examples
danielgtaylor Nov 20, 2020
81e7ab2
chore: constant type names
danielgtaylor Nov 30, 2020
493b586
Merge pull request #11 from istreamlabs/dt/example-array
danielgtaylor Nov 30, 2020
59e246d
feat: use refs for response models in generated OpenAPI
danielgtaylor Dec 19, 2020
68c4145
feat: security & autoconfiguration
danielgtaylor Dec 22, 2020
60df1e3
Merge pull request #12 from istreamlabs/code-sync
danielgtaylor Dec 23, 2020
e8c400a
fix: security reference structure
danielgtaylor Dec 23, 2020
299ffbf
Merge pull request #13 from istreamlabs/auth-ref-fix
danielgtaylor Dec 24, 2020
d91be40
fix: include servers in rendered OpenAPI
danielgtaylor Jan 4, 2021
eb2256a
feat: schema ref generation improvements
danielgtaylor Jan 4, 2021
c3d4059
feat: support CLI auto-config exclude param
danielgtaylor Jan 4, 2021
f77c2b1
Merge pull request #14 from istreamlabs/code-sync
danielgtaylor Jan 4, 2021
eaa86f8
Added 406 (NotAcceptable) to huma responses
Feb 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,024 changes: 484 additions & 540 deletions README.md

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions autoconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package huma

// AutoConfigVar represents a variable given by the user when prompted during
// auto-configuration setup of an API.
type AutoConfigVar struct {
Description string `json:"description,omitempty"`
Example string `json:"example,omitempty"`
Default interface{} `json:"default,omitempty"`
Enum []interface{} `json:"enum,omitempty"`

// Exclude the value from being sent to the server. This essentially makes
// it a value which is only used in param templates.
Exclude bool `json:"exclude,omitempty"`
}

// AutoConfig holds an API's automatic configuration settings for the CLI. These
// are advertised via OpenAPI extension and picked up by the CLI to make it
// easier to get started using an API.
type AutoConfig struct {
Security string `json:"security"`
Headers map[string]string `json:"headers,omitempty"`
Prompt map[string]AutoConfigVar `json:"prompt,omitempty"`
Params map[string]string `json:"params"`
}
2 changes: 1 addition & 1 deletion benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This folder contains four implementations of the same service using the followin
- [FastAPI](https://github.com/tiangolo/fastapi) (Python, popular framework)
- [Gin](https://github.com/gin-gonic/gin) (Go, popular framework)
- [Echo](https://echo.labstack.com/) (Go, popular framework)
- [Huma](https://github.com/danielgtaylor/huma) (Go, this project)
- [Huma](https://github.com/istreamlabs/huma) (Go, this project)

The [wrk](https://github.com/wg/wrk) benchmarking tool is used to make requests against each implementation for 10 seconds with 10 concurrent workers. The results on a 2017 MacBook Pro are shown below:

Expand Down
45 changes: 24 additions & 21 deletions benchmark/fastapi/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions benchmark/fiber/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package main

import (
"strconv"
"strings"

"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)

// Item tracks the price of a good.
type Item struct {
ID int `json:"id"`
Name string `json:"name"`
Price float32 `json:"price"`
IsOffer bool `json:"is_offer,omitempty"`
}

func main() {
app := fiber.New()
app.Use(middleware.Recover())

d := func(c *fiber.Ctx) string {
return strings.Split(c.Get("authorization"), " ")[0]
}

app.Get("/items/:id", func(c *fiber.Ctx) {
tmp := c.Params("id")
id, err := strconv.Atoi(tmp)
if err != nil {
c.Status(500)
return
}

authInfo := d(c)

c.Set("x-authinfo", authInfo)
c.Status(200)
c.JSON(&Item{
ID: id,
Name: "Hello",
Price: 1.25,
IsOffer: false,
})
})

app.Listen("127.0.0.1:8000")
}
10 changes: 10 additions & 0 deletions benchmark/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/istreamlabs/huma/benchmark

go 1.14

require (
github.com/istreamlabs/huma v0.0.0-20200821183705-0c275cfd3c4a
github.com/gin-gonic/gin v1.5.0
github.com/gofiber/fiber v1.13.3
github.com/labstack/echo/v4 v4.1.15
)
Loading