feat(gen): Generate single type for a parameter definition
Description
Given the following definition:
components:
securitySchemes:
parameters:
PathParam:
in: path
name: path-param
required: true
schema:
type: string
enum: ["val1", "val2"]
The generator creates a separate type for this definition whenever this parameter is used. If two operations (oper1, oper2) use this parameter, there will be two generated types (Oper1PathParam, Oper2PathParam). This makes it very difficult to handle such parameters in a common middleware, since they cannot be converted to a string, as that is just an underlying type.
Having a dedicated schema definition that is referenced there is a workaround for this problem. I'm just sure why a separate definition is required in this case.
This would significantly reduce the size of my generated source files and improve debuggability since I reuse a lot of my parameters over many endpoints.
Although I'm not 100% sure how much inlining the Go compiler does, it may even noticeably reduce the binary size which is something I wanted to explore contributing to ogen when I have time. Parameter reuse was my first idea when looking into the generated code.