Description
Hi!
I ran into a panic: duplicate name: Request ...
error when generating the OpenAPI spec in my API. I noticed this happens when I have >1 POST endpoint taking a request body, where the handler defines the input type via an anonymous struct.
e.g..
func handler1(ctx context.Context, input *struct{ Body {...} }) { ... }
func handler2(ctx context.Context, input *struct{ Body {...} }) { ... }
It seems like the issue is that, when using anonymous structs for request bodies, the OpenAPI schema for the request body gets a generic name "Request". When there's more than one, a collision occurs.
Would it be possible to make a unique dynamic name, e.g., by prefixing with the endpoint path, name, etc?
I know that using named structs is an easy workaround, but I think anonymous structs work well for these input types, since they are not passed around or initialized in other code. It keeps the code concise and avoids another thing to name and rename!
Thanks! Been really enjoying this package. You're doing great work.
Activity