You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OperationID from embedded spec doesn't match the original spec #1274
OperationId from the embedded spec is set as GetPet rather than getPet. I used the generated GetSwagger() function to convert embedded spec to openapi3.T object.
this capitalization is done explicitly, see ToCamelCase in the codegen package.
This was probably done so that the generated function always gets exported. Users would probably find it surprising if the capitalization of the operation ID in their spec controlled whether the resulting function is exported or not.
this capitalization is done explicitly, see ToCamelCase in the codegen package. This was probably done so that the generated function always gets exported. Users would probably find it surprising if the capitalization of the operation ID in their spec controlled whether the resulting function is exported or not.
Indeed. I'm trying to write a middleware utilizing Operation ID specified within the embedded spec. However, the capitalization proves to be a challenge, as the ID is case-sensitive according to the OAPI specification.
Right now there's a generation option that controls capitalization of initialims. Perhaps there could be single option that controls various modes of capitalization, including force-camel-case, force-camel-case with Go initialisms, and a new preserve casing option. Then in v2 the initialisms specific parameter could be removed. @jamietanna any thoughts on adding a new parameter for strict case preservation?
From the Openapi 3.1.0 spec:
Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions.
From this, it sounds like OpenAPI recommends we write operation IDs with Go name conventions in mind, so "MyOpID" instead of "myOpId". Of course, that complicates things a tad when you access a single API is shared between languages..
Activity
nickajacks1 commentedon Sep 21, 2023
this capitalization is done explicitly, see ToCamelCase in the codegen package.
This was probably done so that the generated function always gets exported. Users would probably find it surprising if the capitalization of the operation ID in their spec controlled whether the resulting function is exported or not.
skoo25 commentedon Sep 22, 2023
Indeed. I'm trying to write a middleware utilizing Operation ID specified within the embedded spec. However, the capitalization proves to be a challenge, as the ID is case-sensitive according to the OAPI specification.
nickajacks1 commentedon Sep 22, 2023
Right now there's a generation option that controls capitalization of initialims. Perhaps there could be single option that controls various modes of capitalization, including force-camel-case, force-camel-case with Go initialisms, and a new preserve casing option. Then in v2 the initialisms specific parameter could be removed. @jamietanna any thoughts on adding a new parameter for strict case preservation?
From the Openapi 3.1.0 spec:
From this, it sounds like OpenAPI recommends we write operation IDs with Go name conventions in mind, so "MyOpID" instead of "myOpId". Of course, that complicates things a tad when you access a single API is shared between languages..
jamietanna commentedon Nov 28, 2024
I think a good option here - with the current state of the codebase - would be to add a "name normalizer" which is a No-Op for this use-case.
That being said, it'd probably not make sense, as that'd impact all types generated.
An additional parameter for "do not modify
operationIds" would be a good optionfix(codegen): don't
fix(codegen): allow exposing the input spec's `operationId`
fix(codegen): allow exposing the input spec's `operationId`
jamietanna commentedon Apr 7, 2025
This should now be fixed under #1945 which introduces a new configuration option to opt-in to the behaviour.
This is also something that I would see as being a good option to be a default behaviour as of
oapi-codegenv3 (if we ever get there!)fix(codegen): allow exposing the input spec's `operationId`