When running the generated code for Echo Server with Golang version 1.22, it is throwing following errors:
— Build command —
Build Error: go build -o /bin/__debug_bin997619407 -gcflags all=-N -l -ldflags=-X github.com/my-project/pkg/server.version=foo -X github.com/my-project/pkg/server.sha1ver=bar ./main.go
— Error —
github.com/deepmap/oapi-codegen/pkg/codegen
/go/pkg/mod/github.com/deepmap/[email protected]/pkg/codegen/codegen.go:231:53: cannot use spec.Components.Responses (variable of type openapi3.ResponseBodies) as openapi3.Responses value in argument to GenerateResponseDefinitions
/go/pkg/mod/github.com/deepmap/[email protected]/pkg/codegen/codegen.go:403:54: cannot use swagger.Components.Responses (variable of type openapi3.ResponseBodies) as openapi3.Responses value in argument to GenerateTypesForResponses
/go/pkg/mod/github.com/deepmap/[email protected]/pkg/codegen/codegen.go:564:29: invalid operation: cannot index responses (variable of type openapi3.Responses)
/go/pkg/mod/github.com/deepmap/[email protected]/pkg/codegen/filter.go:7:29: cannot use swagger.Paths (variable of type *openapi3.Paths) as openapi3.Paths value in argument to excludeOperationsWithTags
/go/pkg/mod/github.com/deepmap/[email protected]/pkg/codegen/filter.go:10:29: cannot use swagger.Paths (variable of type *openapi3.Paths) as openapi3.Paths value in argument to includeOperationsWithTags
/go/pkg/mod/github.com/deepmap/[email protected]/pkg/codegen/filter.go:19:27: cannot range over paths (variable of type openapi3.Paths)
/go/pkg/mod/github.com/deepmap/[email protected]/pkg/codegen/operations.go:278:45: cannot use responses (variable of type *openapi3.Responses) as openapi3.Responses value in argument to SortedResponsesKeys
/go/pkg/mod/github.com/deepmap/[email protected]/pkg/codegen/operations.go:280:27: invalid operation: cannot index responses (variable of type *openapi3.Responses)
/go/pkg/mod/github.com/deepmap/[email protected]/pkg/codegen/operations.go:539:46: cannot use swagger.Paths (variable of type *openapi3.Paths) as openapi3.Paths value in argument to SortedPathsKeys
/go/pkg/mod/github.com/deepmap/[email protected]/pkg/codegen/operations.go:540:28: invalid operation: cannot index swagger.Paths (variable of type *openapi3.Paths)
/go/pkg/mod/github.com/deepmap/[email protected]/pkg/codegen/operations.go:540:28: too many errors (exit status 1)
— autogenerate command —
//go:generate go run github.com/deepmap/oapi-codegen/cmd/[email protected] –config=models.cfg.yaml ../../spec/v0/server.yaml
//go:generate go run github.com/deepmap/oapi-codegen/cmd/[email protected] –config=server.cfg.yaml ../../spec/v0/server.yaml
— models.cfg.yaml: —
package: models
output: models/models.v0.gen.go
generate:
models: true
compatibility:
always-prefix-enum-values: true
— server.cfg.yaml —
package: api
output: server.v0.gen.go
additional-imports:
package:
alias: .
generate:
echo-server: true
embedded-spec: true
strict-server: true
Tried modifying with different Golang version, oapi-codegen library version etc.
- Expect the go build command to generate the binary and run it successfully