Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example for documentation doesn't work? #263

Open
ScopeSV opened this issue Mar 1, 2024 · 4 comments
Open

example for documentation doesn't work? #263

ScopeSV opened this issue Mar 1, 2024 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@ScopeSV
Copy link

ScopeSV commented Mar 1, 2024

Hi. Im checking out some different solutions for parsing and reading open api, and found your library.
However when testing it with the example, it didn't work.

From the example:

  paths := len(v3Model.Model.Paths.PathItems)
  schemas := len(v3Model.Model.Components.Schemas)

These are pointers, and cannot be checked length on.
However I found that they both have a Len method:

  v3Model.Model.Components.Schemas.Len()

I didnt find a way to iterate over the paths, but I found this blog post
https://quobix.com/articles/parsing-openapi-using-go/
Which does not work, as they are pointers. Couldn't find any iterating methods on the structs either.

Has there been an update lately that may have broken the documentation?

@daveshanley
Copy link
Member

This is a good call out, there have been some major upgrades since that blog post was written - I need to update it.

Check the docs on https://pb33f.io/libopenapi/ for up to date examples.

@daveshanley
Copy link
Member

daveshanley commented Mar 2, 2024

Check out the updated docs here: https://pb33f.io/libopenapi/model/

And there are working examples here: https://github.com/pb33f/libopenapi/blob/main/document_examples_test.go

@ScopeSV
Copy link
Author

ScopeSV commented Mar 2, 2024

Looks good! Thank you very much.

Ive spent some times working with the library and reading on every method and I came up with a similar solution for traversing the openapi, so im happy that was the proper way of doing it :-)

@daveshanley
Copy link
Member

I am keeping this open until I update the blog.

@daveshanley daveshanley added the documentation Improvements or additions to documentation label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants