Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
29 changes: 29 additions & 0 deletions .generator/src/generator/templates/modelOneOf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ public class {{ name }} extends AbstractOpenApiSchema {
Object tmp = null;
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
int match = 0;
{%- set ns = namespace(has_model_list=false) %}
{%- for oneOf in model.oneOf %}
{%- if "items" in oneOf and oneOf.get("items")|is_model and not oneOf|is_primitive %}
{%- set ns.has_model_list = true %}
{%- endif %}
{%- endfor %}
{%- if ns.has_model_list %}
Object deserializedUnparsed = null;
int matchUnparsed = 0;
{%- endif %}
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
{%- for oneOf in model.oneOf %}
{%- set parameterizedDataType = get_type(oneOf) %}
Expand Down Expand Up @@ -103,6 +113,20 @@ public class {{ name }} extends AbstractOpenApiSchema {
deserialized = tmp;
match++;
}
{%- elif "items" in oneOf and oneOf.get("items")|is_model and not oneOf|is_primitive %}
{%- set itemsDataType = get_type(oneOf.get("items")) %}
// keep the matched list, but propagate 'unparsed' from any invalid item
boolean itemsUnparsed = false;
for ({{ itemsDataType }} item : ({{ parameterizedDataType }}) tmp) {
itemsUnparsed |= item.unparsed;
}
if (itemsUnparsed) {
deserializedUnparsed = tmp;
matchUnparsed++;
} else {
deserialized = tmp;
match++;
}
{%- else %}
deserialized = tmp;
match++;
Expand All @@ -118,6 +142,11 @@ public class {{ name }} extends AbstractOpenApiSchema {
{{ name }} ret = new {{ name }}();
if (match == 1) {
ret.setActualInstance(deserialized);
{%- if ns.has_model_list %}
} else if (match == 0 && matchUnparsed == 1) {
ret.setActualInstance(deserializedUnparsed);
ret.unparsed = true;
{%- endif %}
} else {
Map<String, Object> res = new ObjectMapper().readValue(tree.traverse(jp.getCodec()).readValueAsTree().toString(), new TypeReference<Map<String, Object>>() {});
ret.setActualInstance(new UnparsedObject(res));
Expand Down
22 changes: 22 additions & 0 deletions .generator/src/generator/templates/modelSimple.j2
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public class {{ name }} {%- if model.get("x-generate-alias-as-model") %} extends
{%- if (schema.properties is defined or schema.oneOf is defined) and not schema|is_primitive %}
this.unparsed |= {{ variableName }}.unparsed;
{%- endif %}
{%- if "items" in schema and schema.get("items")|is_model and not schema|is_primitive %}
{%- set itemsDataType = get_type(schema.get("items")) %}
for ({{ itemsDataType }} item : {{ variableName }}) {
this.unparsed |= item.unparsed;
}
{%- endif %}
{%- if isNullable %}
}
{%- endif %}
Expand Down Expand Up @@ -257,6 +263,22 @@ public class {{ name }} {%- if model.get("x-generate-alias-as-model") %} extends
this.{{ variableName }} = JsonNullable.<{{ dataType }}>of({{ variableName }});
{%- else %}
this.{{ variableName }} = {{ variableName }};
{%- if not isArray %}
{%- if schema|is_model and not schema|is_primitive %}
if ({{ variableName }} != null) {
this.unparsed |= {{ variableName }}.unparsed;
}
{%- endif %}
{%- else %}
{%- if schema.get("items")|is_model and not schema|is_primitive %}
{%- set itemsDataType = get_type(schema.get("items")) %}
if ({{ variableName }} != null) {
for ({{ itemsDataType }} item : {{ variableName }}) {
this.unparsed |= item.unparsed;
}
}
{%- endif %}
{%- endif %}
{%- endif %}
{%- if model.get("x-keep-typed-in-additional-properties") and model.additionalProperties is not false %}
putAdditionalProperty(JSON_PROPERTY_{{ attr|snake_case|upper }}, {%- if not isRequired and isNullable %} this.{{ variableName }}.orElse(null){%- else %} {{ variableName }}{%- endif %});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public List<AWSAccount> getAccounts() {

public void setAccounts(List<AWSAccount> accounts) {
this.accounts = accounts;
if (accounts != null) {
for (AWSAccount item : accounts) {
this.unparsed |= item.unparsed;
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public List<AWSEventBridgeSource> getEventHubs() {

public void setEventHubs(List<AWSEventBridgeSource> eventHubs) {
this.eventHubs = eventHubs;
if (eventHubs != null) {
for (AWSEventBridgeSource item : eventHubs) {
this.unparsed |= item.unparsed;
}
}
}

public AWSEventBridgeAccountConfiguration tags(List<String> tags) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public List<AWSEventBridgeAccountConfiguration> getAccounts() {

public void setAccounts(List<AWSEventBridgeAccountConfiguration> accounts) {
this.accounts = accounts;
if (accounts != null) {
for (AWSEventBridgeAccountConfiguration item : accounts) {
this.unparsed |= item.unparsed;
}
}
}

public AWSEventBridgeListResponse isInstalled(Boolean isInstalled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public List<AWSLogsAsyncError> getErrors() {

public void setErrors(List<AWSLogsAsyncError> errors) {
this.errors = errors;
if (errors != null) {
for (AWSLogsAsyncError item : errors) {
this.unparsed |= item.unparsed;
}
}
}

public AWSLogsAsyncResponse status(String status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public List<AWSLogsLambda> getLambdas() {

public void setLambdas(List<AWSLogsLambda> lambdas) {
this.lambdas = lambdas;
if (lambdas != null) {
for (AWSLogsLambda item : lambdas) {
this.unparsed |= item.unparsed;
}
}
}

public AWSLogsListResponse services(List<String> services) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public List<AWSTagFilter> getFilters() {

public void setFilters(List<AWSTagFilter> filters) {
this.filters = filters;
if (filters != null) {
for (AWSTagFilter item : filters) {
this.unparsed |= item.unparsed;
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public WidgetTime getTime() {

public void setTime(WidgetTime time) {
this.time = time;
if (time != null) {
this.unparsed |= time.unparsed;
}
}

public AlertGraphWidgetDefinition title(String title) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public List<ApiKey> getApiKeys() {

public void setApiKeys(List<ApiKey> apiKeys) {
this.apiKeys = apiKeys;
if (apiKeys != null) {
for (ApiKey item : apiKeys) {
this.unparsed |= item.unparsed;
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public ApiKey getApiKey() {

public void setApiKey(ApiKey apiKey) {
this.apiKey = apiKey;
if (apiKey != null) {
this.unparsed |= apiKey.unparsed;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public List<ApmStatsQueryColumnType> getColumns() {

public void setColumns(List<ApmStatsQueryColumnType> columns) {
this.columns = columns;
if (columns != null) {
for (ApmStatsQueryColumnType item : columns) {
this.unparsed |= item.unparsed;
}
}
}

public ApmStatsQueryDefinition env(String env) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public List<ApplicationKey> getApplicationKeys() {

public void setApplicationKeys(List<ApplicationKey> applicationKeys) {
this.applicationKeys = applicationKeys;
if (applicationKeys != null) {
for (ApplicationKey item : applicationKeys) {
this.unparsed |= item.unparsed;
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public ApplicationKey getApplicationKey() {

public void setApplicationKey(ApplicationKey applicationKey) {
this.applicationKey = applicationKey;
if (applicationKey != null) {
this.unparsed |= applicationKey.unparsed;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ public List<ResourceProviderConfig> getResourceProviderConfigs() {

public void setResourceProviderConfigs(List<ResourceProviderConfig> resourceProviderConfigs) {
this.resourceProviderConfigs = resourceProviderConfigs;
if (resourceProviderConfigs != null) {
for (ResourceProviderConfig item : resourceProviderConfigs) {
this.unparsed |= item.unparsed;
}
}
}

public AzureAccount secretlessAuthEnabled(Boolean secretlessAuthEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public BarChartWidgetDefinition(
@JsonProperty(required = true, value = JSON_PROPERTY_TYPE)
BarChartWidgetDefinitionType type) {
this.requests = requests;
for (BarChartWidgetRequest item : requests) {
this.unparsed |= item.unparsed;
}
this.type = type;
this.unparsed |= !type.isValid();
}
Expand Down Expand Up @@ -109,6 +112,11 @@ public List<WidgetCustomLink> getCustomLinks() {

public void setCustomLinks(List<WidgetCustomLink> customLinks) {
this.customLinks = customLinks;
if (customLinks != null) {
for (WidgetCustomLink item : customLinks) {
this.unparsed |= item.unparsed;
}
}
}

public BarChartWidgetDefinition description(String description) {
Expand Down Expand Up @@ -159,6 +167,11 @@ public List<BarChartWidgetRequest> getRequests() {

public void setRequests(List<BarChartWidgetRequest> requests) {
this.requests = requests;
if (requests != null) {
for (BarChartWidgetRequest item : requests) {
this.unparsed |= item.unparsed;
}
}
}

public BarChartWidgetDefinition style(BarChartWidgetStyle style) {
Expand All @@ -181,6 +194,9 @@ public BarChartWidgetStyle getStyle() {

public void setStyle(BarChartWidgetStyle style) {
this.style = style;
if (style != null) {
this.unparsed |= style.unparsed;
}
}

public BarChartWidgetDefinition time(WidgetTime time) {
Expand All @@ -203,6 +219,9 @@ public WidgetTime getTime() {

public void setTime(WidgetTime time) {
this.time = time;
if (time != null) {
this.unparsed |= time.unparsed;
}
}

public BarChartWidgetDefinition title(String title) {
Expand Down
Loading
Loading