New fields for client code snippets #5388
Replies: 5 comments 6 replies
-
|
Just off the top of my head:
|
Beta Was this translation helpful? Give feedback.
-
|
We could formalise |
Beta Was this translation helpful? Give feedback.
-
|
I feel like this belongs in the Example Object, rather than at a higher level such as in Operation. |
Beta Was this translation helpful? Give feedback.
-
|
There is already at least one vendor extension, |
Beta Was this translation helpful? Give feedback.
-
|
After looking over this again (and especially at the examples, seeing code embedded in the OAD itself, are you kidding me???!), I'm not convinced this belongs in the OAD at all. The entire point of an OAD is to describe an API thoroughly enough that client code could be created from it that generates a compliant API request. So isn't this something that a vendor tool would provide, either by generating snippets such as these up front or creating the request on demand using OAD data? If I were an API engineer writing an API client against an OAD, I wouldn't be storing my code or scripts in the OAD itself -- I'd do it in separate files and index the interfaces by operation id, because I'd want the code/scripts to be tailored to my specific local environment (using an API gateway, proxy) and authentication keys. tldr: I don't see how publishing this information in the OAD itself would be very interoperable: it's taking the existing generic nature of the OAD and making it less generic for a local environment. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
One of the main scenarios to use OpenAPI is to generate documentation for humans to read.
The specification does a great job at describing all the aspects to craft the HTTP request, and deal with the HTTP response. It also provides "places" to provide examples for both (example, and examples fields). Those are great when using "barebone" HTTP clients on the platform, and crafting payloads manually.
However, more often than not, the API producer may also provide SDKs, or want to provide end to end code snippets for a given operation with the native client for the platform.
I propose that we create such a place so people don't have to rely on extensions for such things! (could be in a SAF as well, depending on where the SAF discussion goes). Here is a quick example
Here a couple of things are interesting:
The snippets entry is at the media type level, this is to account for operations that support multiple media types (e.g. json vs event stream) which would require different client code.
The language part (shell, python, csharp) in the entries would rely on a registry we operate, since there doesn't seem to be an registry for programming languages other than implementations that are specific to platforms (e.g. linguist for GitHub)
The client part (curl, httpx, kiota) could either be another registry, or "free" for anybody to use as they which.
The version part is optional, and can be used in case multiple versions of the same client are being supported/showcased.
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions