Skip to content

Correct openapi3.Unmarshal example #3072

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

Merged
merged 1 commit into from
May 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion content/en/functions/openapi3/Unmarshal.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
To list the GET and POST operations for each of the API paths:

```go-html-template
{{ range $path, $details := $api.Paths }}
{{ range $path, $details := $api.Paths.Map }}
<p>{{ $path }}</p>
<dl>
{{ with $details.Get }}
Expand All @@ -54,6 +54,11 @@
{{ end }}
```

> [!warning]
> The unmarshaled data structure is created with [`kin-openapi`](https://github.com/getkin/kin-openapi). Many fields are structs or pointers (not maps), and therefore require accessors or other methods for indexing and iteration.

Check warning on line 58 in content/en/functions/openapi3/Unmarshal.md

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (unmarshaled)
> For example, prior to [`kin-openapi` v0.122.0](https://github.com/getkin/kin-openapi#v01220) / [Hugo v0.121.0](https://github.com/gohugoio/hugo/releases/tag/v0.121.0), `Paths` was a map (so `.Paths` was iterable) and it is now a pointer (and requires the `.Paths.Map` accessor, as in the example above).
> See the [`kin-openapi` godoc for OpenAPI 3](https://pkg.go.dev/github.com/getkin/kin-openapi/openapi3) for full type definitions.

Hugo renders this to:

```html
Expand Down