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

[Bug]: sharedRoute openapi operationId issue #5513

Open
4 tasks done
csaba-veezla opened this issue Jan 7, 2025 · 0 comments
Open
4 tasks done

[Bug]: sharedRoute openapi operationId issue #5513

csaba-veezla opened this issue Jan 7, 2025 · 0 comments
Assignees
Labels
emitter:openapi3 Issues for @typespec/openapi3 emitter feature New feature or request needs-info Mark an issue that needs reply from the author or it will be closed automatically

Comments

@csaba-veezla
Copy link

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 resulting operationId is rarely unusable for the client code generation.

operationId: operations.map((op) => resolveOperationId(program, op.operation)).join("_"),

As you can see in the playground, it will result in the following shared operationId: Assets_createAsset_Assets_createAssetWithUpload or createAsset_createAsset if you had set the individual operations to createAsset.
Afterward, this will result in something similar in the generated code as well.

I see 2 solutions to this problem:

  • Either it should run a unique on that operations.map, so if all the shared operations have the same operationId, the shared id will be the same.
  • Alternatively, it checks if the shared operations have a provided 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

@csaba-veezla csaba-veezla added the bug Something isn't working label Jan 7, 2025
@csaba-veezla csaba-veezla changed the title [Bug]: sharedRoute openapi issues [Bug]: sharedRoute openapi operationId issue Jan 7, 2025
@markcowl markcowl added the emitter:openapi3 Issues for @typespec/openapi3 emitter label Jan 7, 2025
@markcowl markcowl added feature New feature or request and removed bug Something isn't working labels Jan 8, 2025
@markcowl markcowl added the needs-info Mark an issue that needs reply from the author or it will be closed automatically label Jan 8, 2025
@markcowl markcowl self-assigned this Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:openapi3 Issues for @typespec/openapi3 emitter feature New feature or request needs-info Mark an issue that needs reply from the author or it will be closed automatically
Projects
None yet
Development

No branches or pull requests

2 participants