Open eladb opened 1 year ago
Very cool idea! P2 for now
Hi,
This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!
Hi,
This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!
Feature Spec
The
bring api
statement can be used to obtain a strongly-typed client for making requests to OpenAPI endpoints without needing a dedicated library.As a cloud-oriented language, Wing has built-in support for OpenAPI. For example, when creating a
cloud.Api
resource, it will automatically generate an OpenAPI specification for your endpoints.Similarly, Wing can seamlessly interact with any service that has an OpenAPI specification by automatically generating a strongly-typed client for it.
Let's look at an example. Say we want to interact with OpenAI.
First, we need to download the OpenAPI spec from the OpenAI repository:
Now, we can simply
bring
it into our Wing code:Under the hood, the Wing compiler will generate the following types:
Use Cases
The cloud is an API-driven machine. OpenAPI is becoming the de-facto standard for describing these APIs. Being able to natively use any OpenAPI-based service in Wing is a natural capability of a cloud-oriented language.
Implementation Notes
This is a current limitation of structs that can cause trouble with certain APIs: https://github.com/winglang/wing/issues/2023
For example, the
prompt
field in the OpenAI API is modeled like this:In the above example, we've just selected the first schema (
string
), but ideally I'd want a way to use any of these formats.Component
Language Design, Compiler, SDK
Community Note