-
Notifications
You must be signed in to change notification settings - Fork 66
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
Introduce a new API within the openapi package to convert a Ballerina Type Symbol to a JSON Schema. #7610
Introduce a new API within the openapi package to convert a Ballerina Type Symbol to a JSON Schema. #7610
Comments
OpenAPI type mapper can be used for this purpose. But the schema we build is swagger schema which only utilizes specific fields from JSON schema specification and adds its own set of fields. The swagger exposes an API to convert its schema to JSON schema. We can use that, but it might not be the accurate JSON schema representation since it only support specific JSON schema fields. Ideally, we need a new implementation for type to JSON schema which can be provided by the cc: @MaryamZi @SasinduDilshara
Also, the expand option is currently not available in the Type mapper component. We need to implement this. |
Planned to introduce the following API: It takes the Sample usage: TypeMapper typeMapper = new TypeMapperImpl(context);
// Generation with expansion=true option
String jsonSchemaString = typeMapper.getJsonSchemaString(typeSymbol, true); |
Are we planning to implement and expose this API via the ballerina compiler plugin, or the ballerina-to-openAPI package? |
ballerina-to-openAPI package |
This OpenAPI-based approach works at compile/dev-time, right?
In contrast, this schema generation would happen at runtime. Even if we do have a library function to do this, I believe we'll still need the compile/dev-time schema generation. While we do require runtime schema generation for AI use-cases, I don't think this is a common use-case. We'll discuss this and get back. cc @gimantha |
Problem
The Ballerina agent package requires the generation of JSON Schema from Ballerina type symbols. The objective is to produce an expanded schema. For example, consider the following Ballerina record type
Foo
:The generated schema should adhere to the following format:
Proposed Solution
A new native API may be introduced within the
openapi
package.Alternatives
No response
Version
No response
The text was updated successfully, but these errors were encountered: