Repository navigation
fix(dart): make generated method examples analyze cleanly - #2090
Merged
Merged
Conversation
Examples imported permission.dart and role.dart, which are part files of the main library, so dart analyze rejected them with import_of_non_library; the main library import already brings Permission and Role into scope. Location examples used Uint8List without dart:typed_data, upload examples imported an unused dart:io, and methods without a typed response rendered models. or models.Any where the service returns a plain Future. Validation now extracts every Dart and Flutter docs example and analyzes it against the generated package, like validate-go-examples.sh does for Go.
🟢 Tier S · Ready to merge
The Dart and Flutter method-example templates now emit imports and response assignments that match the generated SDK APIs. A new validator analyzes extracted documentation examples, and the Dart and Flutter validation jobs run it after SDK analysis.
📂 Walkthrough · 4
Reviewed |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Generated Dart and Flutter method examples did not analyze. For example
docs/examples/tablesdb/create-row.mdimportedpackage:dart_appwrite/permission.dartandpackage:dart_appwrite/role.dart, which arepart ofthe main library, sodart analyzereportedimport_of_non_library. The main library import already exposesPermissionandRole, so those imports are dropped.Analyzing every example against the generated package turned up three more failures in the same templates, fixed here too:
Uint8Listwithout importingdart:typed_data.dart:iowithout using it;InputFile(path: ...)needs nothing from it. Flutter still imports it for location examples, which useFile.Futurerenderedmodels. result =(no response model, e.g.analytics.createEvent,oauth2.revoke,project.createSmtpTest) ormodels.Any result =(graphql.query,graphql.mutation). These now await without a typed result, or assign todynamicforany, and skip the unusedmodelsimport.To keep it that way,
scripts/validate-dart-examples.shextracts the code block from every generated docs example, wraps the statements inmain()(the examples use top-levelawait), and runsdart analyze --fatal-warningsinside the generated package. ThedartandflutterValidation jobs run it after analyzing the SDK, mirroringvalidate-go-examples.shfor Go.Test Plan
main, the script fails on the live spec. Dart server: 54 issues (32import_of_non_library, 16undefined_class, 3undefined_identifier, 3unused_import). Flutter client: 27 issues (20import_of_non_library, 2undefined_class, 4undefined_identifier, 1unused_import)../scripts/validate-dart-examples.sh examples/dart(781 examples) and./scripts/validate-dart-examples.sh examples/flutter(191 examples, Flutter 3.38.10) both reportNo issues found!.composer lint-twig,composer refactor:check,max-line-length.sh,shellcheckand the Generation suite pass.Related PRs and Issues
None.
Closes #2091