contiamo / openapi-generator-go

An opinionated OpenAPI v3 code generator for Go. Use this to generate API models and router scaffolding.
MIT License
107 stars 12 forks source link

go install fails with too many errors #156

Open veqryn opened 2 months ago

veqryn commented 2 months ago

Trying to use this project, but I can't even install it: go install github.com/contiamo/openapi-generator-go/v2 Gives too many errors.

I am on Mac OS X with Golang 1.23

go install github.com/contiamo/openapi-generator-go/v2
# github.com/contiamo/openapi-generator-go/v2/pkg/generators/models
../../../../pkg/mod/github.com/contiamo/openapi-generator-go/v2@v2.1.2/pkg/generators/models/generate.go:94:23: invalid argument: g.spec.Paths (variable of type *openapi3.Paths) for built-in len
../../../../pkg/mod/github.com/contiamo/openapi-generator-go/v2@v2.1.2/pkg/generators/models/generate.go:98:30: cannot range over g.spec.Paths (variable of type *openapi3.Paths)
../../../../pkg/mod/github.com/contiamo/openapi-generator-go/v2@v2.1.2/pkg/generators/models/generate.go:236:21: invalid operation: s.Value.Type == "array" (mismatched types *openapi3.Types and untyped string)
../../../../pkg/mod/github.com/contiamo/openapi-generator-go/v2@v2.1.2/pkg/generators/models/go_type_from_ref.go:26:26: cannot use "object" (untyped string constant) as *openapi3.Types value in assignment
../../../../pkg/mod/github.com/contiamo/openapi-generator-go/v2@v2.1.2/pkg/generators/models/go_type_from_ref.go:33:44: invalid operation: propertyType != "array" (mismatched types *openapi3.Types and untyped string)
../../../../pkg/mod/github.com/contiamo/openapi-generator-go/v2@v2.1.2/pkg/generators/models/go_type_from_ref.go:34:18: cannot use "ref" (untyped string constant) as *openapi3.Types value in assignment
../../../../pkg/mod/github.com/contiamo/openapi-generator-go/v2@v2.1.2/pkg/generators/models/go_type_from_ref.go:38:7: cannot convert "object" (untyped string constant) to type *openapi3.Types
../../../../pkg/mod/github.com/contiamo/openapi-generator-go/v2@v2.1.2/pkg/generators/models/go_type_from_ref.go:39:18: cannot use goTypeForObject(schemaRef) (value of type string) as *openapi3.Types value in assignment
../../../../pkg/mod/github.com/contiamo/openapi-generator-go/v2@v2.1.2/pkg/generators/models/go_type_from_ref.go:41:7: cannot convert "string" (untyped string constant) to type *openapi3.Types
../../../../pkg/mod/github.com/contiamo/openapi-generator-go/v2@v2.1.2/pkg/generators/models/go_type_from_ref.go:43:19: cannot use "time.Time" (untyped string constant) as *openapi3.Types value in assignment
../../../../pkg/mod/github.com/contiamo/openapi-generator-go/v2@v2.1.2/pkg/generators/models/go_type_from_ref.go:43:19: too many errors
LucasRoesler commented 2 months ago

unfortunately, i can't reproduce this because I don't have a Mac. However, the cross-compile on Linux to Mac is working successfully for me.

Interestingly, it is also failing in CI during the release build

 # golang.org/x/exp/maps
Error: ../../../go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/maps/maps.go:10:10: syntax error: unexpected [, expecting (
Error: ../../../go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/maps/maps.go:20:12: syntax error: unexpected [, expecting (
Error: ../../../go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/maps/maps.go:30:11: syntax error: unexpected [, expecting (
Error: ../../../go/pkg/mod/golang.org/x/exp@v0.0.0-20230905200255-921286631fa9/maps/maps.go:44:15: syntax error: unexpected [, expecting (

I will need to investigate some more.

LucasRoesler commented 2 months ago

I have reproduced your errors locally and they only happen when kin-openapi is incorrectly upgraded. Which is a very weird thing for go install to do on it's own, it should respect the pinned version in the mod file.