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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions templates/dart/base/utils.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{% macro map_parameter(parameters) %}
{% for parameter in parameters %}
{% if not parameter.nullable and not parameter.required %}
if ({{ parameter.name | caseCamel | overrideIdentifier }} != null) '{{ parameter.name }}': {{ parameter.name | caseCamel | overrideIdentifier }}{% if parameter.enumValues | length > 0 %}!{% endif %}{% if parameter.enumValues | length > 0 %}.value{% endif %},
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition {% if parameter.enumValues | length > 0 %} is duplicated within the same line. Consider simplifying to:

if ({{ parameter.name | caseCamel | overrideIdentifier }} != null) '{{ parameter.name }}': {{ parameter.name | caseCamel | overrideIdentifier }}{% if parameter.enumValues | length > 0  %}!.value{% endif %},

This improves readability and reduces duplication.

Suggested change
if ({{ parameter.name | caseCamel | overrideIdentifier }} != null) '{{ parameter.name }}': {{ parameter.name | caseCamel | overrideIdentifier }}{% if parameter.enumValues | length > 0 %}!{% endif %}{% if parameter.enumValues | length > 0 %}.value{% endif %},
if ({{ parameter.name | caseCamel | overrideIdentifier }} != null) '{{ parameter.name }}': {{ parameter.name | caseCamel | overrideIdentifier }}{% if parameter.enumValues | length > 0 %}!.value{% endif %},

Copilot uses AI. Check for mistakes.
{% else %}
'{{ parameter.name }}': {{ parameter.name | caseCamel | overrideIdentifier }}{% if parameter.enumValues | length > 0 %}{% if not parameter.required %}?{% endif %}.value{% endif %},
{% endif %}
{% endfor %}
{% endmacro %}

Expand Down
3 changes: 0 additions & 3 deletions templates/dart/lib/src/client_mixin.dart.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ mixin ClientMixin {
required Map<String, String> headers,
required Map<String, dynamic> params,
}) {
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the null filtering logic may cause issues with nullable optional parameters. When a nullable optional parameter has a null value:

  1. For multipart/form-data (line 32-33): value.toString() will produce the string "null" instead of omitting the field
  2. For GET requests (line 55): The Uri class's queryParameters may not handle null values as expected
  3. For JSON body (line 59): jsonEncode will include "key": null which may be intended, but differs from the previous behavior where nulls were filtered

Consider either:

  • Adding null checks in the multipart and GET parameter handling code, OR
  • Updating the map_parameter macro in utils.twig to also conditionally include nullable optional parameters when they are null, OR
  • Adding back selective null filtering for nullable optional parameters

This affects how nullable optional parameters are serialized when their value is null.

Copilot uses AI. Check for mistakes.
if (params.isNotEmpty) {
params.removeWhere((key, value) => value == null);
}

http.BaseRequest request = http.Request(method.name(), uri);
if (headers['content-type'] == 'multipart/form-data') {
Expand Down
4 changes: 4 additions & 0 deletions templates/flutter/base/utils.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{%- macro map_parameter(parameters) -%}
{%- for parameter in parameters ~%}
{% if not parameter.nullable and not parameter.required %}
if ({{ parameter.name | caseCamel | overrideIdentifier }} != null) '{{ parameter.name }}': {{ parameter.name | caseCamel | overrideIdentifier }}{% if parameter.enumValues | length > 0 %}!{% endif %}{% if parameter.enumValues | length > 0 %}.value{% endif %},
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition {% if parameter.enumValues | length > 0 %} is duplicated within the same line. Consider simplifying to:

if ({{ parameter.name | caseCamel | overrideIdentifier }} != null) '{{ parameter.name }}': {{ parameter.name | caseCamel | overrideIdentifier }}{% if parameter.enumValues | length > 0  %}!.value{% endif %},

This improves readability and reduces duplication.

Suggested change
if ({{ parameter.name | caseCamel | overrideIdentifier }} != null) '{{ parameter.name }}': {{ parameter.name | caseCamel | overrideIdentifier }}{% if parameter.enumValues | length > 0 %}!{% endif %}{% if parameter.enumValues | length > 0 %}.value{% endif %},
if ({{ parameter.name | caseCamel | overrideIdentifier }} != null) '{{ parameter.name }}': {{ parameter.name | caseCamel | overrideIdentifier }}{% if parameter.enumValues | length > 0 %}!.value{% endif %},

Copilot uses AI. Check for mistakes.
{% else %}
'{{ parameter.name }}': {{ parameter.name | caseCamel | overrideIdentifier }}{% if parameter.enumValues | length > 0 %}{% if not parameter.required %}?{% endif %}.value{% endif %},
{% endif %}
{%- endfor ~%}
{%- endmacro ~%}

Expand Down
3 changes: 0 additions & 3 deletions templates/flutter/lib/src/client_mixin.dart.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ mixin ClientMixin {
required Map<String, String> headers,
required Map<String, dynamic> params,
}) {
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the null filtering logic may cause issues with nullable optional parameters. When a nullable optional parameter has a null value:

  1. For multipart/form-data (line 32): value.toString() will produce the string "null" instead of omitting the field
  2. For GET requests (line 55): The Uri class's queryParameters may not handle null values as expected
  3. For JSON body (line 60): jsonEncode will include "key": null which may be intended, but differs from the previous behavior where nulls were filtered

Consider either:

  • Adding null checks in the multipart and GET parameter handling code, OR
  • Updating the map_parameter macro in utils.twig to also conditionally include nullable optional parameters when they are null, OR
  • Adding back selective null filtering for nullable optional parameters

This affects how nullable optional parameters are serialized when their value is null.

Copilot uses AI. Check for mistakes.
if (params.isNotEmpty) {
params.removeWhere((key, value) => value == null);
}

http.BaseRequest request = http.Request(method.name(), uri);
if (headers['content-type'] == 'multipart/form-data') {
Expand Down
Loading