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 have a handwritten struct that is shared between services in Python, TypeScript, C#, and Go.
The Go version has a field like this (where Date is a custom date type):
EffectiveDateDate`json:"effective"`
It looks like it's currently impossible to generate a drop-in replacement because the field name doesn't match the JSON field name. Would it be possible to add the equivalent of metadata.<lang>Type but for field-naming? I.e., I'd like the schema to be able to generate the field like this:
"effective": {
"metadata": {
"description": "The date that this transaction takes effect",
"goField": "EffectiveDate"
},
"type": "Date"
},
Presumably the TypeScript generator wouldn't offer this option for the reasons explained here, but I think it makes sense to offer it for all other supported languages.
The text was updated successfully, but these errors were encountered:
I have a workaround that seems a bit dangerous, but should be pretty safe:
Assuming the type in question is called MyType, and the generated version lives in a package called generated, the handwritten type can be replaced with a wrapper using MyType as an embedded struct:
typeMyTypestruct {
generated.MyType// EffectiveDate causes 'Effective' to be ignored while marshaling.EffectiveDateDate`json:"effective"`
}
// Effective ensures that clients cannot accidentally access MyType.MyType.Effective.func (mtMyType) Effective() Date {
returnmt.EffectiveDate
}
I have a handwritten struct that is shared between services in Python, TypeScript, C#, and Go.
The Go version has a field like this (where
Date
is a custom date type):It looks like it's currently impossible to generate a drop-in replacement because the field name doesn't match the JSON field name. Would it be possible to add the equivalent of
metadata.<lang>Type
but for field-naming? I.e., I'd like the schema to be able to generate the field like this:Presumably the TypeScript generator wouldn't offer this option for the reasons explained here, but I think it makes sense to offer it for all other supported languages.
The text was updated successfully, but these errors were encountered: