Closed dilanSachi closed 1 month ago
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 - https://github.com/OAI/OpenAPI-Specification/issues/3618
According to the above discussion, this is a valid schema definition.
As per the discussion, the record should have exactly one of url
or html
. In that case the generated records should look like this:
// 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 public type RenderRequest anydata;
at the moment. Will unmark this as a bug and consider this as an improvement.
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.