Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1810,13 +1810,13 @@ func (a *Thing) Set(fieldName string, value interface{}) {
// Override default JSON handling for Thing to handle AdditionalProperties
func (a *Thing) UnmarshalJSON(b []byte) error {
object := make(map[string]json.RawMessage)
err := json.Unmarshal(b, &object)
err := runtime.JSONUnmarshal(b, &object)
if err != nil {
return err
}

if raw, found := object["id"]; found {
err = json.Unmarshal(raw, &a.Id)
err = runtime.JSONUnmarshal(raw, &a.Id)
if err != nil {
return fmt.Errorf("error reading 'id': %w", err)
}
Expand All @@ -1827,7 +1827,7 @@ func (a *Thing) UnmarshalJSON(b []byte) error {
a.AdditionalProperties = make(map[string]interface{})
for fieldName, fieldBuf := range object {
var fieldVal interface{}
err := json.Unmarshal(fieldBuf, &fieldVal)
err := runtime.JSONUnmarshal(fieldBuf, &fieldVal)
if err != nil {
return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err)
}
Expand All @@ -1842,18 +1842,18 @@ func (a Thing) MarshalJSON() ([]byte, error) {
var err error
object := make(map[string]json.RawMessage)

object["id"], err = json.Marshal(a.Id)
object["id"], err = runtime.JSONMarshal(a.Id)
if err != nil {
return nil, fmt.Errorf("error marshaling 'id': %w", err)
}

for fieldName, field := range a.AdditionalProperties {
object[fieldName], err = json.Marshal(field)
object[fieldName], err = runtime.JSONMarshal(field)
if err != nil {
return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err)
}
}
return json.Marshal(object)
return runtime.JSONMarshal(object)
}
```

Expand Down Expand Up @@ -1914,13 +1914,13 @@ func (a *Thing) Set(fieldName string, value int) {
// Override default JSON handling for Thing to handle AdditionalProperties
func (a *Thing) UnmarshalJSON(b []byte) error {
object := make(map[string]json.RawMessage)
err := json.Unmarshal(b, &object)
err := runtime.JSONUnmarshal(b, &object)
if err != nil {
return err
}

if raw, found := object["id"]; found {
err = json.Unmarshal(raw, &a.Id)
err = runtime.JSONUnmarshal(raw, &a.Id)
if err != nil {
return fmt.Errorf("error reading 'id': %w", err)
}
Expand All @@ -1931,7 +1931,7 @@ func (a *Thing) UnmarshalJSON(b []byte) error {
a.AdditionalProperties = make(map[string]int)
for fieldName, fieldBuf := range object {
var fieldVal int
err := json.Unmarshal(fieldBuf, &fieldVal)
err := runtime.JSONUnmarshal(fieldBuf, &fieldVal)
if err != nil {
return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err)
}
Expand All @@ -1946,18 +1946,18 @@ func (a Thing) MarshalJSON() ([]byte, error) {
var err error
object := make(map[string]json.RawMessage)

object["id"], err = json.Marshal(a.Id)
object["id"], err = runtime.JSONMarshal(a.Id)
if err != nil {
return nil, fmt.Errorf("error marshaling 'id': %w", err)
}

for fieldName, field := range a.AdditionalProperties {
object[fieldName], err = json.Marshal(field)
object[fieldName], err = runtime.JSONMarshal(field)
if err != nil {
return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err)
}
}
return json.Marshal(object)
return runtime.JSONMarshal(object)
}
```

Expand Down Expand Up @@ -2028,13 +2028,13 @@ func (a *Thing) Set(fieldName string, value struct {
// Override default JSON handling for Thing to handle AdditionalProperties
func (a *Thing) UnmarshalJSON(b []byte) error {
object := make(map[string]json.RawMessage)
err := json.Unmarshal(b, &object)
err := runtime.JSONUnmarshal(b, &object)
if err != nil {
return err
}

if raw, found := object["id"]; found {
err = json.Unmarshal(raw, &a.Id)
err = runtime.JSONUnmarshal(raw, &a.Id)
if err != nil {
return fmt.Errorf("error reading 'id': %w", err)
}
Expand All @@ -2049,7 +2049,7 @@ func (a *Thing) UnmarshalJSON(b []byte) error {
var fieldVal struct {
Foo *string `json:"foo,omitempty"`
}
err := json.Unmarshal(fieldBuf, &fieldVal)
err := runtime.JSONUnmarshal(fieldBuf, &fieldVal)
if err != nil {
return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err)
}
Expand All @@ -2064,18 +2064,18 @@ func (a Thing) MarshalJSON() ([]byte, error) {
var err error
object := make(map[string]json.RawMessage)

object["id"], err = json.Marshal(a.Id)
object["id"], err = runtime.JSONMarshal(a.Id)
if err != nil {
return nil, fmt.Errorf("error marshaling 'id': %w", err)
}

for fieldName, field := range a.AdditionalProperties {
object[fieldName], err = json.Marshal(field)
object[fieldName], err = runtime.JSONMarshal(field)
if err != nil {
return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err)
}
}
return json.Marshal(object)
return runtime.JSONMarshal(object)
}
```

Expand Down Expand Up @@ -2531,20 +2531,20 @@ type ClientAndMaybeIdentity struct {
// AsClient returns the union data inside the ClientAndMaybeIdentity as a Client
func (t ClientAndMaybeIdentity) AsClient() (Client, error) {
var body Client
err := json.Unmarshal(t.union, &body)
err := runtime.JSONUnmarshal(t.union, &body)
return body, err
}

// FromClient overwrites any union data inside the ClientAndMaybeIdentity as the provided Client
func (t *ClientAndMaybeIdentity) FromClient(v Client) error {
b, err := json.Marshal(v)
b, err := runtime.JSONMarshal(v)
t.union = b
return err
}

// MergeClient performs a merge with any union data inside the ClientAndMaybeIdentity, using the provided Client
func (t *ClientAndMaybeIdentity) MergeClient(v Client) error {
b, err := json.Marshal(v)
b, err := runtime.JSONMarshal(v)
if err != nil {
return err
}
Expand All @@ -2557,20 +2557,20 @@ func (t *ClientAndMaybeIdentity) MergeClient(v Client) error {
// AsIdentity returns the union data inside the ClientAndMaybeIdentity as a Identity
func (t ClientAndMaybeIdentity) AsIdentity() (Identity, error) {
var body Identity
err := json.Unmarshal(t.union, &body)
err := runtime.JSONUnmarshal(t.union, &body)
return body, err
}

// FromIdentity overwrites any union data inside the ClientAndMaybeIdentity as the provided Identity
func (t *ClientAndMaybeIdentity) FromIdentity(v Identity) error {
b, err := json.Marshal(v)
b, err := runtime.JSONMarshal(v)
t.union = b
return err
}

// MergeIdentity performs a merge with any union data inside the ClientAndMaybeIdentity, using the provided Identity
func (t *ClientAndMaybeIdentity) MergeIdentity(v Identity) error {
b, err := json.Marshal(v)
b, err := runtime.JSONMarshal(v)
if err != nil {
return err
}
Expand Down Expand Up @@ -2603,20 +2603,20 @@ func (t *ClientAndMaybeIdentity) UnmarshalJSON(b []byte) error {
// AsClient returns the union data inside the ClientOrIdentity as a Client
func (t ClientOrIdentity) AsClient() (Client, error) {
var body Client
err := json.Unmarshal(t.union, &body)
err := runtime.JSONUnmarshal(t.union, &body)
return body, err
}

// FromClient overwrites any union data inside the ClientOrIdentity as the provided Client
func (t *ClientOrIdentity) FromClient(v Client) error {
b, err := json.Marshal(v)
b, err := runtime.JSONMarshal(v)
t.union = b
return err
}

// MergeClient performs a merge with any union data inside the ClientOrIdentity, using the provided Client
func (t *ClientOrIdentity) MergeClient(v Client) error {
b, err := json.Marshal(v)
b, err := runtime.JSONMarshal(v)
if err != nil {
return err
}
Expand All @@ -2629,20 +2629,20 @@ func (t *ClientOrIdentity) MergeClient(v Client) error {
// AsIdentity returns the union data inside the ClientOrIdentity as a Identity
func (t ClientOrIdentity) AsIdentity() (Identity, error) {
var body Identity
err := json.Unmarshal(t.union, &body)
err := runtime.JSONUnmarshal(t.union, &body)
return body, err
}

// FromIdentity overwrites any union data inside the ClientOrIdentity as the provided Identity
func (t *ClientOrIdentity) FromIdentity(v Identity) error {
b, err := json.Marshal(v)
b, err := runtime.JSONMarshal(v)
t.union = b
return err
}

// MergeIdentity performs a merge with any union data inside the ClientOrIdentity, using the provided Identity
func (t *ClientOrIdentity) MergeIdentity(v Identity) error {
b, err := json.Marshal(v)
b, err := runtime.JSONMarshal(v)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions docs/stdhttp-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func main() {
> If you feel like you've done everything right, but are still receiving `404 page not found` errors, make sure that you've got the `go` directive in your `go.mod` set to at least `1.22`, which enables the enhanced `net/http` routing. In practice it should be at least:

```go.mod
go 1.24
go 1.26
```

> (the `github.com/oapi-codegen/runtime` module imported by the generated code requires Go 1.24+.)
> (the `github.com/oapi-codegen/runtime` module imported by the generated code requires Go 1.26+.)
24 changes: 12 additions & 12 deletions examples/anyof-allof-oneof/anyofallofoneof.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions examples/authenticated-api/echo/api/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading