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;
Comment thread
ddadamhooper marked this conversation as resolved.
}
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
28 changes: 28 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 @@ -114,12 +120,18 @@ public class {{ name }} {%- if model.get("x-generate-alias-as-model") %} extends
{%- else %}
{%- if schema.get("items")|is_model and not schema|is_primitive %}
{%- set itemsDataType = get_type(schema.get("items")) %}
{%- if not isRequired %}
if ({{ variableName }} != null) {
{%- endif %}
for ({{ itemsDataType }} item : {{ variableName }}) {
{%- if schema.enum is defined %}
this.unparsed |= !item.isValid();
{%- endif %}
this.unparsed |= item.unparsed;
}
{%- if not isRequired %}
}
{%- endif %}
{%- endif %}
{%- endif %}
{%- endif %}
Expand Down Expand Up @@ -257,6 +269,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 @@ -29,8 +29,10 @@ public class AWSAccountListResponse {

public AWSAccountListResponse accounts(List<AWSAccount> accounts) {
this.accounts = accounts;
for (AWSAccount item : accounts) {
this.unparsed |= item.unparsed;
if (accounts != null) {
for (AWSAccount item : accounts) {
this.unparsed |= item.unparsed;
}
}
return this;
}
Expand Down Expand Up @@ -58,6 +60,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 @@ -60,8 +60,10 @@ public void setAccountId(String accountId) {

public AWSEventBridgeAccountConfiguration eventHubs(List<AWSEventBridgeSource> eventHubs) {
this.eventHubs = eventHubs;
for (AWSEventBridgeSource item : eventHubs) {
this.unparsed |= item.unparsed;
if (eventHubs != null) {
for (AWSEventBridgeSource item : eventHubs) {
this.unparsed |= item.unparsed;
}
}
return this;
}
Expand Down Expand Up @@ -89,6 +91,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 @@ -35,8 +35,10 @@ public class AWSEventBridgeListResponse {

public AWSEventBridgeListResponse accounts(List<AWSEventBridgeAccountConfiguration> accounts) {
this.accounts = accounts;
for (AWSEventBridgeAccountConfiguration item : accounts) {
this.unparsed |= item.unparsed;
if (accounts != null) {
for (AWSEventBridgeAccountConfiguration item : accounts) {
this.unparsed |= item.unparsed;
}
}
return this;
}
Expand Down Expand Up @@ -65,6 +67,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 @@ -35,8 +35,10 @@ public class AWSLogsAsyncResponse {

public AWSLogsAsyncResponse errors(List<AWSLogsAsyncError> errors) {
this.errors = errors;
for (AWSLogsAsyncError item : errors) {
this.unparsed |= item.unparsed;
if (errors != null) {
for (AWSLogsAsyncError item : errors) {
this.unparsed |= item.unparsed;
}
}
return this;
}
Expand Down Expand Up @@ -64,6 +66,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 @@ -60,8 +60,10 @@ public void setAccountId(String accountId) {

public AWSLogsListResponse lambdas(List<AWSLogsLambda> lambdas) {
this.lambdas = lambdas;
for (AWSLogsLambda item : lambdas) {
this.unparsed |= item.unparsed;
if (lambdas != null) {
for (AWSLogsLambda item : lambdas) {
this.unparsed |= item.unparsed;
}
}
return this;
}
Expand Down Expand Up @@ -89,6 +91,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 @@ -29,8 +29,10 @@ public class AWSTagFilterListResponse {

public AWSTagFilterListResponse filters(List<AWSTagFilter> filters) {
this.filters = filters;
for (AWSTagFilter item : filters) {
this.unparsed |= item.unparsed;
if (filters != null) {
for (AWSTagFilter item : filters) {
this.unparsed |= item.unparsed;
}
}
return this;
}
Expand Down Expand Up @@ -58,6 +60,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 @@ -29,8 +29,10 @@ public class ApiKeyListResponse {

public ApiKeyListResponse apiKeys(List<ApiKey> apiKeys) {
this.apiKeys = apiKeys;
for (ApiKey item : apiKeys) {
this.unparsed |= item.unparsed;
if (apiKeys != null) {
for (ApiKey item : apiKeys) {
this.unparsed |= item.unparsed;
}
}
return this;
}
Expand Down Expand Up @@ -58,6 +60,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 @@ -73,8 +73,10 @@ public ApmStatsQueryDefinition(

public ApmStatsQueryDefinition columns(List<ApmStatsQueryColumnType> columns) {
this.columns = columns;
for (ApmStatsQueryColumnType item : columns) {
this.unparsed |= item.unparsed;
if (columns != null) {
for (ApmStatsQueryColumnType item : columns) {
this.unparsed |= item.unparsed;
}
}
return this;
}
Expand Down Expand Up @@ -102,6 +104,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 @@ -29,8 +29,10 @@ public class ApplicationKeyListResponse {

public ApplicationKeyListResponse applicationKeys(List<ApplicationKey> applicationKeys) {
this.applicationKeys = applicationKeys;
for (ApplicationKey item : applicationKeys) {
this.unparsed |= item.unparsed;
if (applicationKeys != null) {
for (ApplicationKey item : applicationKeys) {
this.unparsed |= item.unparsed;
}
}
return this;
}
Expand Down Expand Up @@ -58,6 +60,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 @@ -410,8 +410,10 @@ public void setResourceCollectionEnabled(Boolean resourceCollectionEnabled) {
public AzureAccount resourceProviderConfigs(
List<ResourceProviderConfig> resourceProviderConfigs) {
this.resourceProviderConfigs = resourceProviderConfigs;
for (ResourceProviderConfig item : resourceProviderConfigs) {
this.unparsed |= item.unparsed;
if (resourceProviderConfigs != null) {
for (ResourceProviderConfig item : resourceProviderConfigs) {
this.unparsed |= item.unparsed;
}
}
return this;
}
Expand Down Expand Up @@ -440,6 +442,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
Loading
Loading