-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Compilation Error with kin-openapi v0.134.0 #2296
Copy link
Copy link
Closed
Description
oapi-codegen v2.6.0 fails to compile when used with kin-openapi v0.134.0 due to a type mismatch error.
The code generation step fails with a compilation error in pkg/codegen/schema.go.
Error Message
go generate ./...
# github.com/oapi-codegen/oapi-codegen/v2/pkg/codegen
../../../../go/pkg/mod/github.com/oapi-codegen/oapi-codegen/v2@v2.6.0/pkg/codegen/schema.go:909:13: invalid operation: v == element.Ref (mismatched types openapi3.MappingRef and string)
openapi/oapicodegen.go:8: running "go": exit status 1
Steps to Reproduce
- Create a project with
go.modthat includes:require ( github.com/getkin/kin-openapi v0.134.0 github.com/oapi-codegen/oapi-codegen/v2 v2.6.0 ) tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen
- Create a oapicodegen.go file
package main //go:generate go tool oapi-codegen -config config.yaml spec.yaml
- Run
go generate ./.. - Observe compilation failure
Expected Behavior
Code generation should complete successfully, as it does with kin-openapi v0.133.0.
Actual Behavior
Compilation fails with type mismatch error. The error suggests that element.Ref changed from type string to openapi3.MappingRef in kin-openapi v0.134.0.
Root Cause
The relevant change in kin-openapi seems to be getkin/kin-openapi@88234d0#diff-e6fbba2cbdca4fd502561d14e4c33ea0080e789c48da5a68814fe196a00dc52aR14-R15
Merge Request: getkin/kin-openapi#1108
Workaround
Downgrade to kin-openapi v0.133.0:
go get github.com/getkin/kin-openapi@v0.133.0
go mod tidy
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels