Skip to content

Conversation

@Lutra-Fs
Copy link

@Lutra-Fs Lutra-Fs commented Jan 1, 2026

Webhook operations were generating broken import statements with Map-style representation and HTML entity encoding:
import '{import=model.Pet, classname=Pet}';

Instead of proper Dart package imports:
import 'package:my-package/src/model/pet.dart';

This occurred because DartDioClientCodegen.postProcessOperationsWithModels() applied import processing to regular operations, but postProcessWebhooksWithModels() was missing the same logic.

Fix:

  • Extracted shared import processing logic into processImports() method, just like C#
  • Added postProcessWebhooksWithModels() override to apply same logic
  • Both operations and webhooks now use consistent import generation

Test:

  • Added verifyWebhookImports() test using existing webhooks.yaml resource
  • Verifies generated code does not contain Map-style imports
  • Verifies generated code does not contain HTML entity encoding

Closes #22586

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 broken Dart Dio webhook imports that were emitted as Map-style, HTML-encoded strings. Webhooks now generate proper package imports and compile correctly. Fixes #22586.

  • Bug Fixes
    • Extracted shared import logic into processImports() and applied it in postProcessWebhooksWithModels() to mirror operations.
    • Added verifyWebhookImports test to ensure no Map-style or HTML-encoded imports.

Written for commit 2dd599c. Summary will update on new commits.

…APITools#22586)

Webhook operations were generating broken import statements with Map-style
representation and HTML entity encoding:
  import '{import=model.Pet, classname=Pet}';

Instead of proper Dart package imports:
  import 'package:my-package/src/model/pet.dart';

This occurred because DartDioClientCodegen.postProcessOperationsWithModels()
applied import processing to regular operations, but postProcessWebhooksWithModels()
was missing the same logic.

Fix:
- Extracted shared import processing logic into processImports() method
- Added postProcessWebhooksWithModels() override to apply same logic
- Both operations and webhooks now use consistent import generation

Test:
- Added verifyWebhookImports() test using existing webhooks.yaml resource
- Verifies generated code does not contain Map-style imports
- Verifies generated code does not contain HTML entity encoding
Copilot AI review requested due to automatic review settings January 1, 2026 05:47
Copy link

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

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java">

<violation number="1" location="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java:750">
P1: Imports are being put on `OperationMap` instead of the parent `OperationsMap`/`WebhooksMap`. The `OperationMap` class doesn&#39;t have imports accessors, while `OperationsMap` and `WebhooksMap` do. This breaks the data structure contract and likely causes template rendering issues. The method signature should accept the parent map to put imports on the correct level.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in the dart-dio generator where webhook operations produced invalid Dart import statements containing Map-style representations and HTML entity encoding instead of proper package imports. The fix extracts shared import processing logic and ensures webhooks receive the same treatment as regular API operations.

Key Changes:

  • Extracted import processing logic into a shared processImports() method to eliminate code duplication
  • Added postProcessWebhooksWithModels() override to apply import processing to webhook operations
  • Fixed a typo in an existing comment ("Uin8List" → "Uint8List")

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
DartDioClientCodegen.java Refactored import processing into shared processImports() method and added webhook support via postProcessWebhooksWithModels() override
DartDioClientCodegenTest.java Added verifyWebhookImports() test to verify webhooks generate valid Dart imports without Map-style syntax or HTML entity encoding

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][dart-dio] Webhook generation produces invalid import statements with HTML entities

1 participant