Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
deeeznuds opened this issue Mar 6, 2023 · 10 comments · May be fixed by #20460
Open

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

deeeznuds opened this issue Mar 6, 2023 · 10 comments · May be fixed by #20460
Assignees

Comments

@deeeznuds
Copy link

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.

@wing328 wing328 transferred this issue from OpenAPITools/openapi-generator-cli Jul 18, 2023
@dexterlakin
Copy link

did you ever fix this? I have the same issue

@affansk
Copy link

affansk commented Sep 6, 2023

same issue

1 similar comment
@hungnm1908
Copy link

same issue

@hungnm1908
Copy link

I have the same issue

@felix0324324
Copy link

Same bug

@affansk
Copy link

affansk commented Oct 27, 2023

I have solved by adding

  1. pubspec.yaml in .openapi-generator-ignore
  2. then changed this :environment:
    sdk: '>=3.0.6 <4.0.0'
  3. dependency_overrides:
    analyzer: 6.2.0

@felix0324324
Copy link

I have solved by adding

  1. pubspec.yaml in .openapi-generator-ignore
  2. then changed this :environment:
    sdk: '>=3.0.6 <4.0.0'
  3. dependency_overrides:
    analyzer: 6.2.0

Great try!!! But I got another method
I just moved my folder.
Before

  • [project]/lib/openapi/lib
    After
  • [project]/lib
  • [project]/openapi/lib

@affansk
Copy link

affansk commented Oct 27, 2023

@felix0324324 it a saying. if it works don't touch it

@davide-bontempelli-zupit

The problem is that dart-dio still requires sdk<3
See here:

sdk: '>={{#useJsonSerializable}}2.17.0{{/useJsonSerializable}}{{^useJsonSerializable}}2.15.0{{/useJsonSerializable}} <3.0.0'

The real solution would be to update the templates and code generation stuff...

@davide-bontempelli-zupit
Copy link

davide-bontempelli-zupit commented Dec 14, 2023

Duplicate of #14863
There you can find an alternative solution

mikefaille added a commit to mikefaille/openapi-generator that referenced this issue Jan 13, 2025
…ues in generated dart-dio clients

This commit fixes compatibility problems between the generated dart-dio code, json_serializable 6.9.0+, and Dart SDK 3.5 or later.

Changes:

- Updated `pubspec.mustache`:
    - Set the minimum SDK constraint for the generated package to `>=3.5.0 <4.0.0`, reflecting the language version used in the generated code.
    - Bump `json_annotation` dependency to `^4.9.0`.
    - Bump `json_serializable` dependency to `^6.9.0`.

These changes ensure that the generated code:

- Is compatible with `json_serializable` 6.9.0+ and Dart SDK 3.5+.
- Avoids Dart 3.5+ specific syntax that causes errors on older SDKs.
- Maintains existing functionality and type safety.

Resolves: OpenAPITools#16117
mikefaille added a commit to mikefaille/openapi-generator that referenced this issue Jan 13, 2025
…ues in generated dart-dio clients

This commit fixes compatibility problems between the generated dart-dio code, json_serializable 6.9.0+, and Dart SDK 3.5 or later.

Changes:

- Updated `pubspec.mustache`:
    - Set the minimum SDK constraint for the generated package to `>=3.5.0 <4.0.0`, reflecting the language version used in the generated code.
    - Bump `json_annotation` dependency to `^4.9.0`.
    - Bump `json_serializable` dependency to `^6.9.0`.

These changes ensure that the generated code:

- Is compatible with `json_serializable` 6.9.0+ and Dart SDK 3.5+.
- Avoids Dart 3.5+ specific syntax that causes errors on older SDKs.
- Maintains existing functionality and type safety.

Resolves: OpenAPITools#16117
mikefaille added a commit to mikefaille/openapi-generator that referenced this issue Jan 13, 2025
…ues in generated dart-dio clients

This commit fixes compatibility problems between the generated dart-dio code, json_serializable 6.9.0+, and Dart SDK 3.5 or later.

Changes:

- Updated `pubspec.mustache`:
    - Set the minimum SDK constraint for the generated package to `>=3.5.0 <4.0.0`, reflecting the language version used in the generated code.
    - Bump `json_annotation` dependency to `^4.9.0`.
    - Bump `json_serializable` dependency to `^6.9.0`.

These changes ensure that the generated code:

- Is compatible with `json_serializable` 6.9.0+ and Dart SDK 3.5+.
- Avoids Dart 3.5+ specific syntax that causes errors on older SDKs.
- Maintains existing functionality and type safety.

Resolves: OpenAPITools#16117, OpenAPITools#14863
mikefaille added a commit to mikefaille/openapi-generator that referenced this issue Jan 14, 2025
…ues in generated dart-dio clients

This commit fixes compatibility problems between the generated dart-dio code, json_serializable 6.9.0+, and Dart SDK 3.5 or later.

Changes:

- Updated `pubspec.mustache`:
    - Set the minimum SDK constraint for the generated package to `>=3.5.0 <4.0.0`, reflecting the language version used in the generated code.
    - Bump `json_annotation` dependency to `^4.9.0`.
    - Bump `json_serializable` dependency to `^6.9.0`.

These changes ensure that the generated code:

- Is compatible with `json_serializable` 6.9.0+ and Dart SDK 3.5+.
- Avoids Dart 3.5+ specific syntax that causes errors on older SDKs.
- Maintains existing functionality and type safety.

Resolves: OpenAPITools#16117, OpenAPITools#14863
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants