thema icon indicating copy to clipboard operation
thema copied to clipboard

Generate something nicer than interfaces when we use disjunctions in Go models.

Open spinillos opened this issue 1 year ago • 0 comments

Given:

myValue: #StructA | #StructB

Generates:

myValue *interface{}

We are loosing the concreteness of the possible values in myValue.

Previously we added fixRawData decorator to remove a lot of autogenerated code that added a lot of functions with a format that we didn't want. It was added to simplify the migration of oapi-codegen library and setting interface{} by default was the easiest solution at this moment.

Removing concreteness forces to generate manual validators and functions to know that the information received on these fields are correct to avoid to save inconsistent information in systems.

We need to evaluate if we can create Validate() error for fields that have these kind of disjuncts and/or functions to retrieve its concrete values.

spinillos avatar May 25 '23 10:05 spinillos