grokify/spectrum

Breaking changes in `kin-openapi` v0.122.0 - change of map definitions

grokify opened this issue · 3 comments

Build fails on v0.122.

% go test -v ./...
# github.com/grokify/spectrum/openapi3
openapi3/merge.go:150:29: cannot range over specExtra.Paths (variable of type *"github.com/getkin/kin-openapi/openapi3".Paths)
openapi3/merge.go:151:44: invalid operation: cannot index specMaster.Paths (variable of type *"github.com/getkin/kin-openapi/openapi3".Paths)
openapi3/merge.go:152:20: invalid operation: cannot index specMaster.Paths (variable of type *"github.com/getkin/kin-openapi/openapi3".Paths)
openapi3/merge.go:155:23: invalid operation: cannot index specMaster.Paths (variable of type *"github.com/getkin/kin-openapi/openapi3".Paths)
openapi3/merge.go:156:21: invalid operation: cannot index specMaster.Paths (variable of type *"github.com/getkin/kin-openapi/openapi3".Paths)
openapi3/merge.go:157:67: invalid operation: cannot index specMaster.Paths (variable of type *"github.com/getkin/kin-openapi/openapi3".Paths)
openapi3/merge.go:162:23: invalid operation: cannot index specMaster.Paths (variable of type *"github.com/getkin/kin-openapi/openapi3".Paths)
openapi3/merge.go:163:21: invalid operation: cannot index specMaster.Paths (variable of type *"github.com/getkin/kin-openapi/openapi3".Paths)
openapi3/merge.go:164:66: invalid operation: cannot index specMaster.Paths (variable of type *"github.com/getkin/kin-openapi/openapi3".Paths)
openapi3/merge.go:169:23: invalid operation: cannot index specMaster.Paths (variable of type *"github.com/getkin/kin-openapi/openapi3".Paths)
openapi3/merge.go:169:23: too many errors

Paths struct definition has changed:

v0.122.0

type Paths struct {
	Extensions map[string]interface{} `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

https://pkg.go.dev/github.com/getkin/kin-openapi@v0.122.0/openapi3#Paths

v0.121.0

type Paths map[string]*PathItem

https://pkg.go.dev/github.com/getkin/kin-openapi@v0.121.0/openapi3#Paths

Diff:

getkin/kin-openapi@v0.121.0...v0.122.0#diff-ba8b4cc8132d631a90f86127c07e39c8b7ead8a9c9ce46388a69d8b7d2b01c03

Solution is to use Paths.Map():

func (paths *Paths) Map() map[string]*PathItem

https://pkg.go.dev/github.com/getkin/kin-openapi@v0.122.0/openapi3#Paths.Map