-
It would be nice if you could customise how embedded structs (anonymous fields) are handled. In particular, I'd like to be able to represent type A struct {
FieldA int `json:"field_a"`
}
type B struct {
A
FieldB int `json:"field_b"`
} as {
"definitions": {
"A": {
"type": "object",
"properties": {
"field_a": {
"type": "integer"
}
}
}
},
"allOf": [
{"$ref": "#/definitions/A"},
{
"type": "object",
"properties": {
"field_b": {
"type": "integer"
}
}
}
]
} At the moment not even the property interceptor seems to get called for embedded structs. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Thank you for an idea, now, with latest version, it is possible to make a reference to embedded struct with a field tag Please check an example of structure. type A struct {
FieldA int `json:"field_a"`
}
type C struct {
jsonschema.EmbedReferencer
FieldC int `json:"field_c"`
}
type B struct {
A `refer:"true"`
FieldB int `json:"field_b"`
C
} |
Beta Was this translation helpful? Give feedback.
-
Closing as per provided new API. |
Beta Was this translation helpful? Give feedback.
-
Moving to Q&A for better visibility. |
Beta Was this translation helpful? Give feedback.
Thank you for an idea, now, with latest version, it is possible to make a reference to embedded struct with a field tag
refer:"true"
, or y implementingjsonschema.EmbedReferencer
on an embedded struct.Please check an example of structure.