[dart-dio] Fix webhook imports generating Map-style strings#22611
[dart-dio] Fix webhook imports generating Map-style strings#22611Lutra-Fs wants to merge 3 commits intoOpenAPITools:masterfrom
Conversation
…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
There was a problem hiding this comment.
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'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.
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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, butpostProcessWebhooksWithModels()was missing the same logic.Fix:
processImports()method, just like C#postProcessWebhooksWithModels()override to apply same logicTest:
verifyWebhookImports()test using existingwebhooks.yamlresourceCloses #22586
PR checklist
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.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)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.
Written for commit 2dd599c. Summary will update on new commits.