-
Notifications
You must be signed in to change notification settings - Fork 94
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
Add support for MarshalJSON
#241
Comments
This could alternatively be a new Example (Apache-2.0 licensed) code that's output from func (a Pong) MarshalJSON() ([]byte, error) {
var err error
object := make(map[string]json.RawMessage)
object["ping"], err = json.Marshal(a.Ping)
if err != nil {
return nil, fmt.Errorf("error marshaling 'ping': %w", err)
}
for fieldName, field := range a.AdditionalProperties {
object[fieldName], err = json.Marshal(field)
if err != nil {
return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err)
}
}
return json.Marshal(object)
} For the following (OpenAPI): Pong:
type: object
required:
- ping
properties:
ping:
type: string
example: pong
additionalProperties:
type: string |
Alternatively could we conditionally generate a |
(This may also need tweaking for the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I couldn't seem to see anything around why there may not be a
MarshalJSON
method as well as anUnmarshalJSON
, is that intended?The text was updated successfully, but these errors were encountered: