-
Notifications
You must be signed in to change notification settings - Fork 65
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
refactor: change swagger operationId output #2129
base: main
Are you sure you want to change the base?
Conversation
aed582f
to
495ed29
Compare
For reference, this is the complete list of
It looks good to me, but we would need to be cautious as we can't reuse method names through controllers, as the controller name would not be part of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@compojoom, amazing work! This will break the SDK generation, but equally allow simplifying it. I have two questions but am otherwise happy to progress with this/fix the generation:
|
Just my 50 cents regarding V1 prefixes: I find them ugly but they will make it easier to migrate the web app because you'll see immediately which types are new and which are old. In this regard, a prefix notation is better than postfix. |
Maybe we should keep the controller name and just remove "controller" string from it?
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#fixed-fields-5 Having the version number at the end felt weirder for me than having it at the begining, but I'm not overly attached to that. Will move it to the end if it makes more sense for you. |
I also found it ugly ,but now that I think of it. If we have 2 operationIds your IDE should offer you autocomplete and you'll see that there is a new v2 version when you start typing "getS"... |
I think it's fine as is but could lead to sneaky bugs in the future. Do you know if there's an error if a conflict happens?
The current SDK implementation generates versions at the end. However, I have no strong opinion as these are used clientside. I'd suggest going with what you prefer and we can then reduce complex name generation from the SDK generation accordingly. |
Yes, checked it. It errors out.
Ok, I'll modfiy the operationId to be controllerName_methodName_version |
Is this then how you would want the wrappers to be named in the SDK, or remain as is? |
495ed29
to
3ec011a
Compare
3ec011a
to
1c7f19e
Compare
Ok, here are the generated operationIds with my latest changes:
You can view here the generated RTK query code: https://github.com/safe-global/safe-wallet-mobile/pull/33 One small annoyance is that the exported RTK hooks, have the Query suffix, so we end up with hooks names like: I think that we will get used to it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
When this is merged, it will beak the SDK generation. If this isn't urgent, I'd suggest merging it Friday and then fixing the aforementioned.
Are we happy to use these names as the "wrappers" there as well? It will make things a lot simple codewise.
Fine with me. I already generated the code for the mobile app baased on this PR. |
Summary
I'm using RTK code generation and the generated code had very ugly names. Here is an example:
I'm getting a lot of java vibes here :) Those method names are auto-generated based on the operationId.
I think that chances of collision are small if we remove the controller from the operationId.
It seems that you guys follow the convension:
AccountsController
so despite the fact that I would remove accountsController of the name I won't have a similar operationId elsewhere as you are adding the controler name in the function
With this approach we end up with code like this:
WDYT?
@iamacook is this change going to be problematic for your client-gateway-typescript-sdk?