起きたこと
openapi-generator generateで dart-dio を生成してアプリをデバッグしようとしたところ The language version override has to be the same in the library and its part(s).
エラー
エラー詳細
ファイル名は変更しています
Launching lib/main.dart on iPhone SE (3rd generation) in debug mode... main.dart:1 Xcode build done. 15.0s Failed to build iOS app Error (Xcode): lib/client/lib/src/model/sample_request.dart:9:6: Error: The language version override has to be the same in the library and its part(s). sample_request.dart:9 Could not build the application for the simulator. Error launching application on iPhone SE (3rd generation). Exited
自分の解決法
openapi関連ディレクトリをlibと同じ階層に持ってくる
エラーが起きた当初、下記コマンドでgenerateしlibの中にclientディレクトリを入れていた
openapi-generator generate -i openapi.yaml -g dart-dio -o ./lib/client
これでは実行時に先述のエラーが出たため以下で実行し直した
openapi-generator generate -i openapi.yaml -g dart-dio -o ./openapi/client
これでいけました。
なぜlibの中にclientディレクトリを入れていたか
dart関連のファイルをlibの外に出すのが何となく違和感があったため