Code Monkey home page Code Monkey logo

Comments (10)

sebastienlevert avatar sebastienlevert commented on June 9, 2024 1

Do we have better ways to generate operation Ids based on the path? I feel it would be a lot more dev friendly.

from kiota.

baywet avatar baywet commented on June 9, 2024

@maisarissi what would you have as a placeholder?
I'm assuming the sliced description also needs the operationId to be set, correct?

from kiota.

sebastienlevert avatar sebastienlevert commented on June 9, 2024

They are not required. At runtime, random GUIDs will be generated to ensure their unicity.

from kiota.

baywet avatar baywet commented on June 9, 2024

so we don't need to change anything here?

from kiota.

sebastienlevert avatar sebastienlevert commented on June 9, 2024

We need to generate the functions in the plugin for sure. If they are not generated, they are ignored and won't get called.

from kiota.

baywet avatar baywet commented on June 9, 2024

ok so back to my previous question, I'm guessing we're using a guid as a placeholder. And I'm guessing the sliced description needs the same guid as operation id?

from kiota.

maisarissi avatar maisarissi commented on June 9, 2024

Maybe we could generate an operationId combining the endpoint with the HTTP method?
Something like: posts#GET could be posts-list, then posts/{posts-id}#GET could be posts-get, posts#PATCH posts-patch, posts/{posts-id}/comments#GET posts-comments-list, posts/{posts-id}/comments/{comment-id}#GET posts-comments-get and so on and so forth.

from kiota.

andrueastman avatar andrueastman commented on June 9, 2024

According to the validator, we would need the operationId to have the format ^[a-zA-Z0-9_]*$ (essentially number,digits and underscores). So, using something like posts-list would lead to validation error by the plugins lib and we would need to use underscores instead rather than the dash.

Another idea is that we can use the same logic Kiota uses for namespacing for a path and append the operation name at the end and separating them with underscores.
posts#GET => posts_get
posts/{posts-id}#GET => posts_item_get
posts/{posts-id}/comments#GET => posts_item_comments_get
posts/{posts-id}/comments/{comment-id}#GET => posts_item_comments_item_get

Back to the question by @baywet, we probably need to answer,

  • Should the openApi file that is also generated/sliced from the original description at output also be updated with the added operationIds to match?
  • Should we attempt to sanitize operationId for the sake of the validator if the original operationId does not match the plugin validation rules? (and update the openApi description as well?).

from kiota.

sebastienlevert avatar sebastienlevert commented on June 9, 2024

That's a great proposal @andrueastman. I think this would be optimal! For the questions:

  • I'd say yes. The orchestrator will report on the operationIds used (not the function names from the plugin) and it'll be super useful for debugging later as devs will know which operation was called.
  • This is a good question... And I think this is a fair way to ensure success. I'd vote for sanitizing both the plugin function names and the operationIds in a consistent manner. Basically "always" sanitize them to ensure full supportability.

from kiota.

maisarissi avatar maisarissi commented on June 9, 2024

Agree with @sebastienlevert.

  • Yes, we should add the operationIds to the sliced OpenAPI description.
  • If the existing operationId in the original OpenAPI document does not match with the validation rules, we should ensure success and sanitize them to successfully generate the sliced OpenAPI and the plugin.

from kiota.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.