Open
Description
What version of ogen are you using?
v0.54.1
Can this issue be reproduced with the latest version?
Yes just try to run this test in directory where API is generated with OptString
package api
import (
"testing"
"encoding/json"
)
func TestOpString(t *testing.T) {
s := OptString{}
_, err := json.Marshal(s)
if err != nil {
t.Fatalf("error should be nil, got %v", err)
}
}
So for most use cases with fields set to not required when trying to marshal it (e.g. send through event bus) it's not possible to use ogen.
Getting output:
--- FAIL: TestOpString (0.00s)
/Users/exu/code/kube/testkube-cloud-api/pkg/api/optstring_test.go:16:
error should be nil, got json: error calling MarshalJSON for type api.OptString:
unexpected end of JSON input