karlvr / openapi-generator-plus

A code generator for OpenAPI written in node and designed to have pluggable generators

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add metadata for CodegenNativeType

karlvr opened this issue · comments

In the generator templates we make changes to native types when the type is used. Such as to make a type primitive or java.util.Optional (Java) or ? (Swift). In the template files we have to attempt to reproduce that logic when deciding whether to unwrap optionals or not.

Let's introduce metadata as a Record<string, unknown> on CodegenNativeType and its associated transformers. We can then add metadata to a type when we create it, such as to say that it's not optional and then through the transformer when we transform the type we can add a property to say that the type is optional.

When we want to access the untransformed type, we could probably simply go to the schema to get it.