OpenAPITools / OpenAPITools/openapi-generator

[BUG][DART] The language version override has to be the same in the library and its part(s).

Open
#14,863 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

I ran into a dart versioning problem. My project has sdk: '>=2.17.0 <3.0.0', and openapi-cli generated API has sdk: '>=2.14.0 <3.0.0'. I can not downgrade my project SDK version, but when I manually change SDK version in "generated_api/pubscpec.yaml", the project builds without errors.
I search possibilities to set up a custom SDK version for openapi-generator-cli before generating API, but found nothing.
Is there any solution for manually or automatically determining the SDK version to avoid such a problem?

openapi-generator version

// https://mvnrepository.com/artifact/org.openapitools/openapi-generator-cli
compileOnly 'org.openapitools:openapi-generator-cli:6.3.0'

OpenAPI declaration file content or url

My declaration JSON file without errors, I can't share it due to my company's policy.

Generation Details

java -jar C:\Users\DEV\Documents\openapi-generator-cli.jar generate -i https://test-example.com/api/v2/api-docs -g dart-dio -o C:\Users\DEV\Documents\Projects\mobile\lib\api -p pubLibrary=mobile.api,pubName=mobile_api,serializationLibrary=json_serializable

Steps to reproduce

Set up in project's pubspec.yaml file SDK version like this:
environment:
sdk: '>=2.17.0 <3.0.0'

Then generate API via openapi-generator-cli.
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs

Build app, then in the debug logs you will see "The language version override has to be the same in the library and its part(s)." error.

Suggest a fix

Add the ability to manually or automatically determine the SDK version.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the dart-dio generator entry point and the generated pubspec.yaml files, using the reported SDK ranges and generation command to reproduce the language-version mismatch. Done means the generated library and its parts use a manually supplied or automatically determined SDK version consistently, and the documented Flutter build steps complete without the override error.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
api, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.