-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add operation ids to external API description #1445
Conversation
@Leptopoda, please have a look at this PR if that is as you think it useful. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #1445 +/- ##
=======================================
Coverage 79.35% 79.35%
=======================================
Files 86 86
Lines 2548 2548
=======================================
Hits 2022 2022
Misses 526 526
Flags with carried forward coverage won't be shown. Click here to find out more. |
I don't think underscrore is the right way to go. Depending on the generator used it will generate something like: final API _api = API();
final CategoriesApi _categoryAPI = _api.categories;
final Response<RecipeStub> _response= await _categoryAPI.recipes_in_category(id: "12345678");
if(response.code == 200){
print(response.data)
} In this case having Taking those and the aforementioned camelcase into consideration I'd name this particular endpoint final _api = API();
final _categoryAPI = _api.categories;
final _response = await _categoryAPI.getRecipes(id: "12345678");
if(response.code == 200){
print(response.data)
} As dart can do type inference I could even leave out the type declarations as seen above. Obviously I'm biased and prefer the style of the language I like/use most but I think the same should at least apply to java/kotlin. (iirc the preferd method naming scheme is camelcase and at least the official swagger kotlin generator does produce objects for each api endpoint). Finally I've also found a few other problems with the spec that I'd like to discuss as they might also need server side changes while hopefully not being considered breaking. Therefore I'd not close the issue #1421 and change the PR content. I've experimented with some changes already and played arround with them locally so theres nothing final or PR ready as of now (the reason I didn't go forward with them yet) but I'll attach my current version below. |
Yes, it is true that PascalCase and camelCase are the typical stylings for many modern languages. However, there are case-insensitive languages and these fail at either of these. Using kebab-case works well in YAML but might cause trouble with code generation (the minus might be a subtraction sign). In general, this can be discussed if we keep the names unique with case-insensitive comparisons.
Here there is no real alternative. According to the official documentation the operation ID must ba a unique string. As we have a way to get all recipes for a keyword, for a category, in a search and all recipes unconditionally, we must use appropriate names for these.
Let's focus here on the operation ID in this PR. |
Yeah I forgot about that :(
Can you please name me any relevant one? Also I can't imagine someone writing an API client in languages like Pascal :) Also a look at the languages supported by the official swagger/openapi codegenerator reveals that case insensitivity probably isn't a Problem.
I could only imagine things like Haskell being problematic as they require method names starting with a capital letter (AFAIK). |
Signed-off-by: Christian Wolf <[email protected]>
Signed-off-by: Christian Wolf <[email protected]>
Signed-off-by: Christian Wolf <[email protected]>
Signed-off-by: Christian Wolf <[email protected]>
3d42e57
to
789ca85
Compare
/approve |
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.
Automatically approved by GitHub action on behalf of /approve
Closes #1421