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

How to use Openapi Generator Dart with Dart 3 ? #146

Open
linh232323 opened this issue Apr 24, 2024 · 2 comments
Open

How to use Openapi Generator Dart with Dart 3 ? #146

linh232323 opened this issue Apr 24, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@linh232323
Copy link

Description of the bug

Could not generate project with dart 3

Steps to reproduce

Using Dart SDK version: 3.3.4 (stable) (Tue Apr 16 19:56:12 2024 +0000) on "macos_arm64"
Run generate and pubspec.yaml as

environment:
  sdk: '>=2.7.0 <3.0.0'

Expected behavior

Openapi-Generator-Dart should generate dart 3 project with pubspec env as

environment:
  sdk: '>=3.0.0 <4.0.0'

Logs

No response

Screenshots

No response

Platform

macOS

Library version

5.0.2

Flutter version

3.19.6

Flutter channel

stable

Additional context

No response

@linh232323 linh232323 added the bug Something isn't working label Apr 24, 2024
@gawi151
Copy link

gawi151 commented Aug 14, 2024

It's not possible as https://github.com/OpenAPITools/openapi-generator generates only Dart 2 code. Both vanila and dio versions.

@Vitaliy-Svinchyak
Copy link

The only problem I faced with dart 3 was that mixins are defined as abstract classes which is not a valid code in dart 3.
I run this bash script after codegen to fix it:

#!/bin/bash
MODEL_DIRECTORY="./lib/sdk/lib/src/model/"

for file in "$MODEL_DIRECTORY"/*; do
  if [ -f "$file" ]; then
    sed -i '' "s/abstract class _/mixin _/Ig" "$file"
    echo "Moved to mixins in: $file"
  fi
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants