pb33f/libopenapi

Example not compiling due to error: cannot range over docModel.Model.Paths.PathItems

ajb-neodynamics-io opened this issue · 4 comments

I'm following the example illustrated here:
https://quobix.com/articles/parsing-openapi-using-go/

But I'm running into an issue where I'm getting a compile error:
internal/config/config.go:131:34: cannot range over docModel.Model.Paths.PathItems (variable of type *"github.com/pb33f/libopenapi/orderedmap".Map[string, *"github.com/pb33f/libopenapi/datamodel/high/v3".PathItem])

The code I'm attempting to run is exactly the same as the code in the tutorial. I literally cut and paste it:
image

Any idea why I continue to get the following error:
image

MacOS version Sonoma 14.5
Go version 1.22
libopenapi version 0.16.8

I though it may be because the petstorev3.json file that the tutorial prompts you to download is actually written in yaml, but changing the extension to .yaml did not work, same error.

Trying another example from the "Installing" section of the guide works as expected:
image

And I get the expected result:
image

But when I try to range over the v3Model.Model.Paths.PathItems I get the same error as in my first post.

Hi There, This is the same issue as #263

I need to update my blog is the correct answer - the API changed a while back and it means we now use ordered maps, instead of a regular map. This allows us to keep ordering in place when re-rendering the spec back out.

I will now go and update my blog however.

OK. I updated the blog! The example code is using the new API and I added some notes.

Thank you for the nudge!