Skip to content

[dart-dio] fix the issue of multi layer issues with dart-dio code generation - #23717

Open
fstotz wants to merge 20 commits into
OpenAPITools:masterfrom
fstotz:feature/dart_dio_fix_one_of_multi_layers
Open

[dart-dio] fix the issue of multi layer issues with dart-dio code generation#23717
fstotz wants to merge 20 commits into
OpenAPITools:masterfrom
fstotz:feature/dart_dio_fix_one_of_multi_layers

Conversation

@fstotz

@fstotz fstotz commented May 7, 2026

Copy link
Copy Markdown

This fixes the issues with multi layer class using oneOf in dart-dio
fixes #15467

The PR includes test for dart-dio, which are using the example from the ticket

@jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes multi-level oneOf/anyOf discriminator handling and tightens parameter/serializer generation in dart-dio. Previously discriminator mappings leaked across layers and order favored parents; null query params were emitted as empty strings and form fields used query encoders; array path params and nullable collection builders were mis-generated.

  • Discriminators: keep only schema-declared mappings for local discriminators; for inherited discriminators, include true allOf descendants plus oneOf/anyOf alternatives declared on the current schema; order by inheritance depth so subclasses are checked first; expose x-discriminator-mapped-models-nonself, x-has-discriminator-self-mapping, and x-discriminator-self-mapping-name (addresses [BUG] [dart-dio] Discriminator with multi-layered subclasses causes the subclasses to have error in discriminators #15467, preserves declared alternatives per [dart-dio] fix the issue of multi layer issues with dart-dio code generation #23717).
  • Parameters: encodeQueryParameter/encodeCollectionQueryParameter return null for null input; generated APIs call removeNullQueryParametersExcept to drop nulls while preserving required-nullable entries; add api_util.dart for both built_value and json_serializable. Path params use api/path_param: non-containers call .toString(); array path params encode via encodeCollectionQueryParameter. Non-multipart form fields use encodeFormParameter/encodeCollectionFormParameter in built_value.
  • Serializers: generate ListBuilder<T?>/SetBuilder<T?> when item types are nullable to match FullType.nullable(...).

Written for commit 90f0a6e. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 13 files

}
}

private int getSchemaInheritanceDepth(String schemaName, String ancestorSchemaName, Set<String> visited) {

@wing328 wing328 May 21, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: what about adding docstrings explaining what this function and other newly added functions do?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@wing328 I did add some comments and also fixed another issue in regards to a possible null cast
Could you take another look?

@wing328 wing328 modified the milestones: 7.23.0, 7.24.0 Jun 8, 2026
@fstotz
fstotz requested a review from wing328 June 8, 2026 07:56
@wing328 wing328 modified the milestones: 7.24.0, 7.25.0 Jul 20, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

4 issues found across 22 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/StringPatternsWithOneOf.cs">

<violation number="1" location="samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/StringPatternsWithOneOf.cs:129">
P2: The deserializer always throws. `varString` is initialized to `default` and never assigned anywhere in the read loop (the property-name `switch` only has `default: break;`), so `if (varString != null)` is always false and every valid JSON object throws `JsonException`. The `String` property can never be populated, breaking the model for any real request/response. The generator logic that populates the local from the matched property is missing.</violation>

<violation number="2" location="samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/StringPatternsWithOneOf.cs:157">
P2: Serialization drops the value. `Write` calls `WriteProperties`, whose body is empty and never emits the `String` property, so the generated output is always an empty object `{}`. Combined with the always-throwing `Read`, the model cannot round-trip its data in either direction.</violation>
</file>

<file name="samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api_util.dart">

<violation number="1" location="samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api_util.dart:41">
P2: When a required-but-nullable path parameter is null, generated path interpolation now produces the literal `null` segment. Preserve path-specific empty/validation behavior instead of returning null from the shared path encoder.</violation>

<violation number="2" location="samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api_util.dart:41">
P2: When a nullable non-multipart form parameter is null, generated code now passes a null body value through `encodeQueryParameter`. Route form fields through `encodeFormParameter` or remove null form entries before Dio encodes the request.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

/// <param name="stringPatternsWithOneOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(Utf8JsonWriter writer, StringPatternsWithOneOf stringPatternsWithOneOf, JsonSerializerOptions jsonSerializerOptions)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: Serialization drops the value. Write calls WriteProperties, whose body is empty and never emits the String property, so the generated output is always an empty object {}. Combined with the always-throwing Read, the model cannot round-trip its data in either direction.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/StringPatternsWithOneOf.cs, line 157:

<comment>Serialization drops the value. `Write` calls `WriteProperties`, whose body is empty and never emits the `String` property, so the generated output is always an empty object `{}`. Combined with the always-throwing `Read`, the model cannot round-trip its data in either direction.</comment>

<file context>
@@ -0,0 +1,162 @@
+        /// <param name="stringPatternsWithOneOf"></param>
+        /// <param name="jsonSerializerOptions"></param>
+        /// <exception cref="NotImplementedException"></exception>
+        public void WriteProperties(Utf8JsonWriter writer, StringPatternsWithOneOf stringPatternsWithOneOf, JsonSerializerOptions jsonSerializerOptions)
+        {
+
</file context>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this issue is not related to this PR
It only appeared after creating the examples

}
}

if (varString != null)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: The deserializer always throws. varString is initialized to default and never assigned anywhere in the read loop (the property-name switch only has default: break;), so if (varString != null) is always false and every valid JSON object throws JsonException. The String property can never be populated, breaking the model for any real request/response. The generator logic that populates the local from the matched property is missing.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/csharp/generichost/latest/AnnotatedEnum/src/Org.OpenAPITools/Model/StringPatternsWithOneOf.cs, line 129:

<comment>The deserializer always throws. `varString` is initialized to `default` and never assigned anywhere in the read loop (the property-name `switch` only has `default: break;`), so `if (varString != null)` is always false and every valid JSON object throws `JsonException`. The `String` property can never be populated, breaking the model for any real request/response. The generator logic that populates the local from the matched property is missing.</comment>

<file context>
@@ -0,0 +1,162 @@
+                }
+            }
+
+            if (varString != null)
+                return new StringPatternsWithOneOf(varString);
+
</file context>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this issue is not related to this PR
It only appeared after creating the examples

) {
if (value == null) {
return '';
return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: When a required-but-nullable path parameter is null, generated path interpolation now produces the literal null segment. Preserve path-specific empty/validation behavior instead of returning null from the shared path encoder.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api_util.dart, line 41:

<comment>When a required-but-nullable path parameter is null, generated path interpolation now produces the literal `null` segment. Preserve path-specific empty/validation behavior instead of returning null from the shared path encoder.</comment>

<file context>
@@ -38,7 +38,7 @@ dynamic encodeQueryParameter(
 ) {
   if (value == null) {
-    return '';
+    return null;
   }
   if (value is String || value is num || value is bool) {
</file context>

) {
if (value == null) {
return '';
return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: When a nullable non-multipart form parameter is null, generated code now passes a null body value through encodeQueryParameter. Route form fields through encodeFormParameter or remove null form entries before Dio encodes the request.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/api_util.dart, line 41:

<comment>When a nullable non-multipart form parameter is null, generated code now passes a null body value through `encodeQueryParameter`. Route form fields through `encodeFormParameter` or remove null form entries before Dio encodes the request.</comment>

<file context>
@@ -38,7 +38,7 @@ dynamic encodeQueryParameter(
 ) {
   if (value == null) {
-    return '';
+    return null;
   }
   if (value is String || value is num || value is bool) {
</file context>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

3 issues found and verified against the latest diff

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="modules/openapi-generator/src/main/resources/dart/libraries/dio/api.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/dart/libraries/dio/api.mustache:90">
P1: For the json_serializable serialization library, this call produces an undefined function. removeNullQueryParameters only exists in built_value's api_util.dart, which is neither generated nor imported under JSON serializable (DartDioClientCodegen.java only adds api_util.dart for built_value). Any operation with a query param generated with --serialization-library json_serializable will fail to compile. Guard the call so it is only emitted for built_value (e.g. wrap in {{#useBuiltValue}}...) or provide the function for json_serializable too.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/api_util.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/api_util.mustache:82">
P1: removeNullQueryParameters is added only to the built_value api_util, but the shared api.mustache calls it for every dio serialization flavor. The native/json_serializable flavor doesn't generate an api_util, so its generated API code calls an undefined removeNullQueryParameters and fails to compile. Define/emit removeNullQueryParameters for the non-built_value serialization library as well, or gate the call.</violation>
</file>

<file name="samples/server/petstore/java-vertx-web-interface-only/src/main/java/org/openapitools/vertxweb/server/HttpServerVerticle.java">

<violation number="1" location="samples/server/petstore/java-vertx-web-interface-only/src/main/java/org/openapitools/vertxweb/server/HttpServerVerticle.java:23">
P2: When this verticle runs outside the Maven project root, `RouterBuilder.create` cannot find the OpenAPI document because `specFile` points into the source tree. Load `openapi.yaml` from the classpath using a Vert.x-supported resource/content overload instead of a source-relative filesystem path.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

{{/queryParams}}
};{{/hasQueryParams}}{{#hasBodyOrFormParams}}
};
removeNullQueryParameters(_queryParameters);{{/hasQueryParams}}{{#hasBodyOrFormParams}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1: For the json_serializable serialization library, this call produces an undefined function. removeNullQueryParameters only exists in built_value's api_util.dart, which is neither generated nor imported under JSON serializable (DartDioClientCodegen.java only adds api_util.dart for built_value). Any operation with a query param generated with --serialization-library json_serializable will fail to compile. Guard the call so it is only emitted for built_value (e.g. wrap in {{#useBuiltValue}}...) or provide the function for json_serializable too.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/dart/libraries/dio/api.mustache, line 90:

<comment>For the json_serializable serialization library, this call produces an undefined function. removeNullQueryParameters only exists in built_value's api_util.dart, which is neither generated nor imported under JSON serializable (DartDioClientCodegen.java only adds api_util.dart for built_value). Any operation with a query param generated with --serialization-library json_serializable will fail to compile. Guard the call so it is only emitted for built_value (e.g. wrap in {{#useBuiltValue}}...) or provide the function for json_serializable too.</comment>

<file context>
@@ -86,7 +86,8 @@ class {{classname}} {
       {{/queryParams}}
-    };{{/hasQueryParams}}{{#hasBodyOrFormParams}}
+    };
+    removeNullQueryParameters(_queryParameters);{{/hasQueryParams}}{{#hasBodyOrFormParams}}
 
     dynamic _bodyData;
</file context>

throw ArgumentError('Invalid value passed to encodeCollectionQueryParameter');
}

void removeNullQueryParameters(Map<String, dynamic> queryParameters) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1: removeNullQueryParameters is added only to the built_value api_util, but the shared api.mustache calls it for every dio serialization flavor. The native/json_serializable flavor doesn't generate an api_util, so its generated API code calls an undefined removeNullQueryParameters and fails to compile. Define/emit removeNullQueryParameters for the non-built_value serialization library as well, or gate the call.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/api_util.mustache, line 82:

<comment>removeNullQueryParameters is added only to the built_value api_util, but the shared api.mustache calls it for every dio serialization flavor. The native/json_serializable flavor doesn't generate an api_util, so its generated API code calls an undefined removeNullQueryParameters and fails to compile. Define/emit removeNullQueryParameters for the non-built_value serialization library as well, or gate the call.</comment>

<file context>
@@ -49,26 +49,37 @@ dynamic encodeQueryParameter(
   throw ArgumentError('Invalid value passed to encodeCollectionQueryParameter');
 }
+
+void removeNullQueryParameters(Map<String, dynamic> queryParameters) {
+  queryParameters.removeWhere((_, value) => value == null);
+}
</file context>

public class HttpServerVerticle extends AbstractVerticle {

private static final Logger logger = LoggerFactory.getLogger(HttpServerVerticle.class);
private static final String specFile = "src/main/resources/openapi.yaml";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: When this verticle runs outside the Maven project root, RouterBuilder.create cannot find the OpenAPI document because specFile points into the source tree. Load openapi.yaml from the classpath using a Vert.x-supported resource/content overload instead of a source-relative filesystem path.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/server/petstore/java-vertx-web-interface-only/src/main/java/org/openapitools/vertxweb/server/HttpServerVerticle.java, line 23:

<comment>When this verticle runs outside the Maven project root, `RouterBuilder.create` cannot find the OpenAPI document because `specFile` points into the source tree. Load `openapi.yaml` from the classpath using a Vert.x-supported resource/content overload instead of a source-relative filesystem path.</comment>

<file context>
@@ -0,0 +1,63 @@
+public class HttpServerVerticle extends AbstractVerticle {
+
+    private static final Logger logger = LoggerFactory.getLogger(HttpServerVerticle.class);
+    private static final String specFile = "src/main/resources/openapi.yaml";
+
+    
</file context>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this issue is not related to this PR
It only appeared after creating the examples

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 25 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 24 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/api/serialize.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/api/serialize.mustache:12">
P1: For non-multipart forms with array (container) form params, form_param.mustache renders a call to `encodeCollectionFormParameter<T>(...)`, but api_util.mustache only defines `encodeCollectionQueryParameter`. The regenerated sample confirms it: `fake_api.dart` calls `encodeCollectionFormParameter<String>` while `api_util.dart` never declares it, so the generated Dart won't compile for this case. Add `encodeCollectionFormParameter` to api_util.dart (mirroring `encodeCollectionQueryParameter` but returning form-encoded values), or keep the query_param partial here for collection params.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

_bodyData = <String, dynamic>{
{{#formParams}}
{{^required}}{{^isNullable}}if ({{{paramName}}} != null) {{/isNullable}}{{/required}}r'{{{baseName}}}': {{>serialization/built_value/api/query_param}},
{{^required}}{{^isNullable}}if ({{{paramName}}} != null) {{/isNullable}}{{/required}}r'{{{baseName}}}': {{>serialization/built_value/api/form_param}},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1: For non-multipart forms with array (container) form params, form_param.mustache renders a call to encodeCollectionFormParameter<T>(...), but api_util.mustache only defines encodeCollectionQueryParameter. The regenerated sample confirms it: fake_api.dart calls encodeCollectionFormParameter<String> while api_util.dart never declares it, so the generated Dart won't compile for this case. Add encodeCollectionFormParameter to api_util.dart (mirroring encodeCollectionQueryParameter but returning form-encoded values), or keep the query_param partial here for collection params.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/built_value/api/serialize.mustache, line 12:

<comment>For non-multipart forms with array (container) form params, form_param.mustache renders a call to `encodeCollectionFormParameter<T>(...)`, but api_util.mustache only defines `encodeCollectionQueryParameter`. The regenerated sample confirms it: `fake_api.dart` calls `encodeCollectionFormParameter<String>` while `api_util.dart` never declares it, so the generated Dart won't compile for this case. Add `encodeCollectionFormParameter` to api_util.dart (mirroring `encodeCollectionQueryParameter` but returning form-encoded values), or keep the query_param partial here for collection params.</comment>

<file context>
@@ -9,7 +9,7 @@
       _bodyData = <String, dynamic>{
         {{#formParams}}
-        {{^required}}{{^isNullable}}if ({{{paramName}}} != null) {{/isNullable}}{{/required}}r'{{{baseName}}}': {{>serialization/built_value/api/query_param}},
+        {{^required}}{{^isNullable}}if ({{{paramName}}} != null) {{/isNullable}}{{/required}}r'{{{baseName}}}': {{>serialization/built_value/api/form_param}},
         {{/formParams}}
       };
</file context>

…ze path_param templates

- Create form_param.mustache for built_value using encodeFormParameter
- Update serialize.mustache to use form_param include for non-multipart forms
- Simplify path_param.mustache to call .toString() directly on parameters
- Conditionally apply null checks only for nullable parameters
- Remove unnecessary wrapping parentheses and trailing newlines for clean formatting

Fixes Issue 4 (form params incorrectly using query encoder)

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 5 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

fstotz and others added 2 commits August 20, 2026 13:52
Array path parameters now use encodeCollectionQueryParameter instead of
.toString(), which produces Dart list literals like [1,2,3] unencoded.
Mirrors query_param logic to handle collection types with proper encoding.

Addresses P2 issue from review.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 8 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/api/path_param.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/api/path_param.mustache:1">
P1: When `serializationLibrary=json_serializable` and an operation has a container path parameter, this branch emits built_value-only code. The json_serializable API does not define or import these symbols, so generated Dart fails to compile; use a JSON-specific path encoder instead.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

@@ -0,0 +1 @@
{{#isContainer}}{{#isNullable}}{{{paramName}}} == null ? '' : encodeCollectionQueryParameter<{{{baseType}}}>(_serializers, {{{paramName}}}, const FullType(Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]), {{#collectionFormat}}format: ListFormat.{{collectionFormat}},{{/collectionFormat}}){{/isNullable}}{{^isNullable}}encodeCollectionQueryParameter<{{{baseType}}}>(_serializers, {{{paramName}}}, const FullType(Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]), {{#collectionFormat}}format: ListFormat.{{collectionFormat}},{{/collectionFormat}}){{/isNullable}}{{/isContainer}}{{^isContainer}}{{#isNullable}}{{{paramName}}} == null ? '' : {{{paramName}}}.toString(){{/isNullable}}{{^isNullable}}{{{paramName}}}.toString(){{/isNullable}}{{/isContainer}} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1: When serializationLibrary=json_serializable and an operation has a container path parameter, this branch emits built_value-only code. The json_serializable API does not define or import these symbols, so generated Dart fails to compile; use a JSON-specific path encoder instead.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/api/path_param.mustache, line 1:

<comment>When `serializationLibrary=json_serializable` and an operation has a container path parameter, this branch emits built_value-only code. The json_serializable API does not define or import these symbols, so generated Dart fails to compile; use a JSON-specific path encoder instead.</comment>

<file context>
@@ -1 +1 @@
-{{#isNullable}}{{{paramName}}} == null ? '' : {{{paramName}}}.toString(){{/isNullable}}{{^isNullable}}{{{paramName}}}.toString(){{/isNullable}}
\ No newline at end of file
+{{#isContainer}}{{#isNullable}}{{{paramName}}} == null ? '' : encodeCollectionQueryParameter<{{{baseType}}}>(_serializers, {{{paramName}}}, const FullType(Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]), {{#collectionFormat}}format: ListFormat.{{collectionFormat}},{{/collectionFormat}}){{/isNullable}}{{^isNullable}}encodeCollectionQueryParameter<{{{baseType}}}>(_serializers, {{{paramName}}}, const FullType(Built{{#isMap}}Map{{/isMap}}{{#isArray}}{{#uniqueItems}}Set{{/uniqueItems}}{{^uniqueItems}}List{{/uniqueItems}}{{/isArray}}, [{{#isMap}}FullType(String), {{/isMap}}FullType({{{baseType}}})]), {{#collectionFormat}}format: ListFormat.{{collectionFormat}},{{/collectionFormat}}){{/isNullable}}{{/isContainer}}{{^isContainer}}{{#isNullable}}{{{paramName}}} == null ? '' : {{{paramName}}}.toString(){{/isNullable}}{{^isNullable}}{{{paramName}}}.toString(){{/isNullable}}{{/isContainer}}
\ No newline at end of file
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] [dart-dio] Discriminator with multi-layered subclasses causes the subclasses to have error in discriminators

2 participants