Open Cidan opened 8 months ago
We use openapi code generator to generates these types from an API spec. Unfortunately, we are restricted by that.
Fortunately, you are not restricted as this is an option in oapi-codegen, which you use. You must update the schema to add x-go-type-name
to the affected fields, which thankfully aren't that many at all.
I need to stress here that currently, the client is incredibly cumbersome to use without this change and will make adoption very difficult. I'm not sure what the authoritative source for the openapi spec is though.
Fortunately, you are not restricted as this is an option in oapi-codegen, which you use. You must update the schema to add
x-go-type-name
to the affected fields, which thankfully aren't that many at all.I need to stress here that currently, the client is incredibly cumbersome to use without this change and will make adoption very difficult. I'm not sure what the authoritative source for the openapi spec is though.
Up! Please, it would be a welcome implementation. Go as you know is a stong typed language, having anonymous nested structs greatly lowers the dev experience.
The api spec is maintained here: https://github.com/typesense/typesense-api-spec/blob/master/openapi.yml
Happy to accept a PR for this change.
see: https://github.com/typesense/typesense-go/blob/4d2cad02695cd09c26543af066a1219de1522b2f/typesense/api/types_gen.go#L153
Nested structs should not be anonymous structs, as this makes it so the caller needs to define the struct manually in order to pass it in as an argument to the function.