-
Notifications
You must be signed in to change notification settings - Fork 65
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
OneOf with several fields declared as required generates anydata
type
#6127
Comments
Do you mean something like this: public type RenderRequestOptional record {|
boolean block_ads?;
boolean click_accept?;
string delay?;
"png"| "jpg"| "pdf"| "svg"| "mp4"| "webp"| "webm"| "html" format?;
boolean full_page?;
boolean gpu?;
int height?;
boolean hide_cookie_banners?;
string html?;
boolean metadata?;
boolean retina?;
string selector?;
int thumb_height?;
int thumb_width?;
string url?;
string wait_for?;
string wait_to_leave?;
"requestsfinished"|"mostrequestsfinished"|"loaded"|"domloaded" wait_until?;
int width?;
|};
public type RenderRequestWithUrl record {|
*RenderRequestOptional;
string url;
|};
public type RenderRequestWithHtml record {|
*RenderRequestOptional;
string html;
|};
public type RenderRequest RenderRequestWithUrl|RenderRequestWithHtml; |
Added a question on OAS spec also - OAI/OpenAPI-Specification#3618 |
According to the above discussion, this is a valid schema definition. |
As per the discussion, the record should have exactly one of // Note that the `url` and `html` fields are not defined in this record
public type RenderRequestCommon record {|
boolean block_ads?;
boolean click_accept?;
string delay?;
"png"| "jpg"| "pdf"| "svg"| "mp4"| "webp"| "webm"| "html" format?;
boolean full_page?;
boolean gpu?;
int height?;
boolean hide_cookie_banners?;
boolean metadata?;
boolean retina?;
string selector?;
int thumb_height?;
int thumb_width?;
string wait_for?;
string wait_to_leave?;
"requestsfinished"|"mostrequestsfinished"|"loaded"|"domloaded" wait_until?;
int width?;
|};
public type RenderRequestWithUrl record {|
*RenderRequestOptional;
string url;
|};
public type RenderRequestWithHtml record {|
*RenderRequestOptional;
string html;
|};
public type RenderRequest RenderRequestWithUrl|RenderRequestWithHtml; |
As this is a rare case and will be complex to implement, we only generate |
Close this issue since this is not in the 80% case |
Description:
Consider the following component schema.
Atm, what we generate for this is,
As it is difficult to denote
oneof
& required types in a ballerina record. We can either generate 2 records with the 2 required oneof fields or generate a union type with the 2 required fields.The text was updated successfully, but these errors were encountered: