-
Notifications
You must be signed in to change notification settings - Fork 232
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
[Bug]: sharedRoute openapi operationId issue #5513
Comments
Hi @csaba-veezla, thank you for reaching out! From my understanding, you are expecting to achieve the desired result both when the Could you please provide more details on your expectations for the generated results in the following scenarios?
|
Ohh, so I should have imported I'll try my best to elaborate. Since I have proposed two distinct solutions to the issue, I'll provide two separate answers, to address your questions. 1st Solution: "Unique ID" (Everyone contributes, but it's like brainstorming—each unique idea counts only once, the first time)
2nd Solution: "Has Operation ID" (Only contributors are recognized if any exists)
While I am not entirely familiar with the code of the emitter, it seems to me that the 1st solution (unique) would be I hope I was able to answer the questions clearly, convey the issue effectively, and present the proposed solutions more comprehensively. |
Describe the bug
We have a use case where you can create assets in our system; the source of an asset can differ.
So for the same endpoint, we support both "multipart/form-data" and "application/json" as content types.
The two operations are slightly different from each other, so we are leveraging the
@sharedRoute
operator.The issue comes from the open API emitter. It concatenates the
operationIds
, and the resultingoperationId
is rarely unusable for the client code generation.typespec/packages/openapi3/src/openapi.ts
Line 687 in fef1c39
As you can see in the playground, it will result in the following shared operationId:
Assets_createAsset_Assets_createAssetWithUpload
orcreateAsset_createAsset
if you had set the individual operations tocreateAsset
.Afterward, this will result in something similar in the generated code as well.
I see 2 solutions to this problem:
unique
on thatoperations.map
, so if all the shared operations have the same operationId, the shared id will be the same.operationId
and it joins the the ones that have some, or if there is none, it generates the one that it does right now (mostly will result in the same json as it does now, backward compatible)Reproduction
I tried to reduce the code to the minimum, but I couldn't make the
operationId
decorator work, it should be part of the@typespec/openapi3
lib, so I'm not sure, what I am missing:playground
Checklist
The text was updated successfully, but these errors were encountered: