swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.01k stars 6.03k forks source link

Flutter not building - seems like codegen doesn't support Dart 2.1 #9422

Open YishTish opened 5 years ago

YishTish commented 5 years ago
Description

Trying to build code generated by codegen for Dart/Flutter project and getting the following error:

The current Dart SDK version is 2.1.2-dev.0.0.flutter-0a7dcf17eb. Because MeBa depends on swagger from path which requires SDK version <2.0.0, version solving failed. pub get failed (1)

Swagger-codegen version

2.4.5 (latest as of 3-Feb-2019)

Swagger declaration file content or url

My Flutter pubspec: YAML: name: MeBa description: My First Flutter project version: 1.0.0+1

environment: sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies: flutter: sdk: flutter

cupertino_icons: ^0.1.2

english_words: ^3.1.0 http: ^0.12.0+1 google_sign_in: ^4.0.1+1 firebase_auth: ^0.7.0 cloud_firestore: date_format: ^1.0.6 font_awesome_flutter: ^8.4.0 flutter_datetime_picker: ^1.1.3 shared_preferences: ^0.5.1+2 json_annotation: ^2.2.0 build_runner: ^1.2.0 swagger: path: ./swagger

dev_dependencies: json_serializable: ^2.1.2 flutter_test: sdk: flutter

flutter: uses-material-design: true

assets:

Command line used for generation

flutter packages get build

Steps to reproduce

Copy files generated by codegen (I used the run-in-docker command) to the project root directory, under "swagger". Link to it under dependencies/swagger, and run build.

Related issues/PRs
Suggest a fix/enhancement

I am trying to understand where the Dart limitation, to be <2 is defined. I checked the one dependency Swagger has, http, and it looks up to date.

Thanks in advance.

lingster commented 5 years ago

Hi, I had a similar problem when I used swagger-codegen and added the swagger code to my project. Can you try adding the following to the end of your swagger/pubspec.yaml file:

environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"
Morkos commented 5 years ago

Hi Ling,

That works. However, now I'm getting a very similar set of errors to here: https://github.com/swagger-api/swagger-codegen/issues/3421

.dart files containing HTML entities ("\<", "\>") and the file names themselves.

Any library to pass in for dart, similar to java to fix this issue?

Here's the JSON spec: https://gist.github.com/Morkos/66be7d70657f7e6cd6cb8f4de01d28ff

Here's the compilation errors: https://gist.github.com/Morkos/d3cd7ad271fcf8dd489af575ab5138a6

Dart: 2.5.0 Swagger Codegen: V2.4.8 Language: Dart Ran 'mvn clean package' and regenerated dart libraries but still doesn't compile

Thank you,