-
Notifications
You must be signed in to change notification settings - Fork 161
Support custom format types. #1335
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or requestopenapi-featuresOpenAPI features support issuesOpenAPI features support issues
Description
Description
I'd like to propose adding support for custom format types. These could come from the configuration. Maybe something like the following example:
generator:
formats:
decimal: github.com/shopspring/decimal.DecimalThis would result in a field with format: decimal to be of the type decimal.Decimal from the package github.com/shopspring/decimal.
Alternatively, we could implement this as an extension e.g.
type: string
x-ogen-type: github.com/shopspring/decimal.DecimalWe can implement some checks to ensure the package is importable, as well as checking that the type implements one of the following interfaces:
interface {
Encode(e *jx.Encoder)
Decode(d *jx.Decoder) error
}interface {
json.Marshaler
json.Unmarshaler
}interface {
encoding.TextMarshaler
encoding.TextUnmarshaler
}Based on which of the interfaces it implements we can use a different template for encoding and decoding the value.
I'm happy to implement this feature, just wanted to first check if such a feature would be accepted and get alignment on the way it's configured.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestopenapi-featuresOpenAPI features support issuesOpenAPI features support issues