You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I discovered a panic through a test where the Info was missing. I understand it's a required field but I would have expected an error from the loader, not a panic when marshalling.
This is roughly how I discovered it:
loader:=&openapi3.Loader{}
doc, err:=loader.LoadFromData([]byte("{}"))
require.NoError(t, err) // Doesn't error// This panics on v0.125.0 but not v0.124.0yaml.Marshal(doc)
This is of course simplified. In my actual code I have some transformations going on between that and it loads from a file. If all you want to do is reproduce the panic you can do yaml.Marshal(&openapi3.Loader{}). Interestingly yaml.Marshal(openapi3.Loader{}) still doesn't panic.
Here's the relevant stacktrace, trimmed down a little:
case Marshaler:
v, err:=value.MarshalYAML()
iferr!=nil {
fail(err)
}
It assumes that value will be a pointer, but it's not guaranteed. Here's the issue in yaml.v3: go-yaml/yaml#747
I don't think there's anything to be done in kin-openapi. I would suggest you to switch to a different library, as yaml.v3 seems abandoned. For example: https://pkg.go.dev/github.com/goccy/go-yaml
I discovered a panic through a test where the
Info
was missing. I understand it's a required field but I would have expected an error from the loader, not a panic when marshalling.This is roughly how I discovered it:
This is of course simplified. In my actual code I have some transformations going on between that and it loads from a file. If all you want to do is reproduce the panic you can do
yaml.Marshal(&openapi3.Loader{})
. Interestinglyyaml.Marshal(openapi3.Loader{})
still doesn't panic.Here's the relevant stacktrace, trimmed down a little:
The text was updated successfully, but these errors were encountered: