-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Issue Description
I've tried running the starting example from README with just the health endpoint. It panics on gen.Parse.
Steps to Reproduce
- run the following code
package main
import (
"github.com/gin-gonic/gin"
"github.com/ls6-events/astra"
"github.com/ls6-events/astra/inputs"
"github.com/ls6-events/astra/outputs"
)
func main() {
r := gin.Default()
r.GET("/health", func(c *gin.Context) {
c.JSON(200, gin.H{
"status": "ok",
})
})
gen := astra.New(inputs.WithGinInput(r), outputs.WithOpenAPIOutput("openapi.generated.yaml"))
// For OpenAPI to work, we need to define a configuration, which contains the title, version and description amongst other important information
config := &astra.Config{
Title: "Example API",
Version: "1.0.0",
Host: "localhost",
Port: 8000,
}
// Either way, you need to set the config for the OpenAPI generator to use
gen.SetConfig(config)
err := gen.Parse()
if err != nil {
panic(err)
}
err = r.Run(":8000")
if err != nil {
panic(err)
}
}
Expected Behavior
For it to not panic and give an OpenAPI spec.
Actual Behavior
It panics after the error is returned on gen.Parse().
Output:
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
[GIN-debug] GET /health --> main.main.func1 (3 handlers)
8:53AM INF Begin parsing
8:53AM INF Setting up parse
8:53AM INF Setting up
8:53AM INF Creating temp dir
8:53AM INF Creating temp dir complete
8:53AM INF Noting current dir
8:53AM INF Noting current dir complete
8:53AM INF Setting up complete
8:53AM INF Creating routes from inputs
8:53AM INF Creating routes from input mode=gin
8:53AM INF Creating routes from input complete mode=gin
8:53AM INF Creating routes from inputs complete
8:53AM INF Setting up parse complete
8:53AM INF Completing parse
8:53AM INF Parsing routes from inputs
8:53AM INF Parsing routes from input mode=gin
8:53AM ERR Failed to get package error="package my-package/.astra/astramain has list errors" file=cmd/astra-test/astra-test.go method=GET path=/health
8:53AM ERR Failed to parse route error="package my-package/.astra/astramain has list errors" file=cmd/astra-test/astra-test.go line=13 method=GET path=/health
8:53AM ERR Error creating routes from input error="package my-package/.astra/astramain has list errors" mode=gin
8:53AM ERR Error parsing routes from inputs error="package my-package/.astra/astramain has list errors"
8:53AM ERR Error completing parse error="package my-package/.astra/astramain has list errors"
panic: package my-package/.astra/astramain has list errors
goroutine 1 [running]:
main.main()
/Users/marko/Workspace/my-package/cmd/astra-test/astra-test.go:35 +0x426
Exiting.
Additional Information
- Go Version: go version go1.23.1 darwin/amd64
- Go Toolchain:
- Astra Version: v1.23.1
Metadata
Metadata
Assignees
Labels
No labels