Open JayaniH opened 8 months ago
Yeah, it is possible to write the required fields in the given schemas in the way you have described. Currently, tool support required fields can be defined under the object schema itself. The given example has an advanced scenario that creates one object schema by combining multiple object schemas. We can provide a workaround till we provide a proper fix for this.
workaround: you can move the required field details to its particular object schema. This will allow you to get the mandatory fields for the mentioned schemas as expected.
For example, the createChatCompletionResponse
schema[example 02] has five required fields, some of which (id, object, created, and model) are defined under the chatCompletionsResponseCommon
reference schema. Therefore, we can make the choices
field required for the inline object schema itself in the 'createChatCompletionResponse` schema.
Please see the workaround below:
createChatCompletionResponse:
type: object
allOf:
- $ref: '#/components/schemas/chatCompletionsResponseCommon'
- properties:
choices:
type: array
items:
type: object
allOf:
- $ref: '#/components/schemas/chatCompletionChoiceCommon'
- properties:
message:
$ref: '#/components/schemas/chatCompletionResponseMessage'
content_filter_results:
$ref: '#/components/schemas/contentFilterResults'
required:
- choices
We will try to provide an improvement from the tool ASAP and will update the issue with the progress.
Description: When using the OpenAPI tool to generate a connector from the OpenAPI specification, some properties which are indicated as required in the schema are indicated as optional in the generated Ballerina record types.
Example 1 (CreateChatCompletionRequest - messages field)
Schema:
Generated type:
Example 2 (CreateChatCompletionResponse - choices field)
Schema:
Generated type:
Example 3 (ExtensionsChatCompletionsRequest - messages field)
Schema:
Generated type:
Steps to reproduce: The above examples are from the connector generated from the yaml of this specification.
Affected Versions:
OS, DB, other environment details and versions:
Related Issues (optional):
Suggested Labels (optional):
Suggested Assignees (optional):