Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested structs in type_gen should not be anonymous structs #154

Open
Cidan opened this issue Dec 20, 2023 · 4 comments
Open

Nested structs in type_gen should not be anonymous structs #154

Cidan opened this issue Dec 20, 2023 · 4 comments

Comments

@Cidan
Copy link

Cidan commented Dec 20, 2023

see:

Embed *struct {

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.

@kishorenc
Copy link
Member

We use openapi code generator to generates these types from an API spec. Unfortunately, we are restricted by that.

@Cidan
Copy link
Author

Cidan commented Dec 21, 2023

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.

@luigibarbato
Copy link

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.

@kishorenc
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants