epam-cross-platform-lab / swagger-dart-code-generator

Swagger/OpenAPI code generator based on Chopper and JsonAnnotation for Flutter
Apache License 2.0
257 stars 118 forks source link

[BUG] - api generation with multiple flavours: 'class-modifiers' language feature to be enabled #748

Open morofir opened 4 months ago

morofir commented 4 months ago

while trying to generate using the library im getting an exceptions. i want to create different ChopperService foe each flavor. full terminal log:

flutter pub run build_runner build --delete-conflicting-outputs

Deprecated. Use `dart run` instead.
Resolving dependencies... (1.8s)
Downloading packages... 
Got dependencies.
Resolving dependencies... 
Downloading packages... 
Got dependencies.
[INFO] Generating build script completed, took 797ms
[WARNING] Throwing away cached asset graph because the build phases have changed. This most commonly would happen as a result of adding a new dependency or updating your dependencies.
[WARNING] Throwing away cached asset graph because the language version of some package(s) changed. This would most commonly happen when updating dependencies or changing your min sdk constraint.
[INFO] Cleaning up outputs from previous builds. completed, took 1.4s
[INFO] Generating build script completed, took 222ms
[WARNING] Invalidated precompiled build script due to missing asset graph.
[INFO] Precompiling build script... completed, took 20.7s
[INFO] Building new asset graph completed, took 3.6s
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[WARNING] No actions completed for 16.5s, waiting on:
  - swagger_dart_code_generator on lib/swaggers/dp_prod.yaml
  - swagger_dart_code_generator on lib/swaggers/mg_prod.yaml
  - swagger_dart_code_generator on lib/swaggers/mg_qa.yaml
  - swagger_dart_code_generator on lib/swaggers/dp_dev.yaml
  - swagger_dart_code_generator on lib/swaggers/mg_dev.yaml
  .. and 1 more

[WARNING] No actions completed for 51.5s, waiting on:
  - swagger_dart_code_generator on lib/swaggers/dp_prod.yaml
  - swagger_dart_code_generator on lib/swaggers/mg_prod.yaml
  - swagger_dart_code_generator on lib/swaggers/mg_qa.yaml
  - swagger_dart_code_generator on lib/swaggers/dp_dev.yaml
  - swagger_dart_code_generator on lib/swaggers/mg_dev.yaml
  .. and 1 more

[SEVERE] swagger_dart_code_generator on lib/swaggers/dp_prod.yaml:

HandshakeException: Handshake error in client (OS Error: errno = 0)
[WARNING] No actions completed for 19.7s, waiting on:
  - swagger_dart_code_generator on lib/swaggers/mg_prod.yaml
  - swagger_dart_code_generator on lib/swaggers/mg_qa.yaml
  - swagger_dart_code_generator on lib/swaggers/dp_dev.yaml
  - swagger_dart_code_generator on lib/swaggers/mg_dev.yaml
  - swagger_dart_code_generator on lib/swaggers/dp_qa.yaml

[INFO] Generating SDK summary completed, took 7.4s
[WARNING] No actions completed for 19.1s, waiting on:
  - json_serializable on integration_test/page_object/reminders_test_page.dart
  - json_serializable on integration_test/first_test.dart
  - json_serializable on integration_test/page_object/register_test_page.dart
  - json_serializable on integration_test/page_object/bec_test_page.dart
  - json_serializable on integration_test/page_object/dp_session_summary_test_page.dart
  .. and 11 more

[SEVERE] chopper_generator on lib/api/swagger.swagger.dart:

Could not format because the source could not be parsed:

line 3, column 1 of .: This requires the 'class-modifiers' language feature to be enabled.
  ╷
3 │ final class _$Swagger extends Swagger {_$Swagger([ChopperClient? client]) { if (client == null) return;
  │ ^^^^^
  ╵
[SEVERE] chopper_generator on lib/api/mg_prod.swagger.dart:

Could not format because the source could not be parsed:

line 3, column 1 of .: This requires the 'class-modifiers' language feature to be enabled.
  ╷
3 │ final class _$MgProd extends MgProd {_$MgProd([ChopperClient? client]) { if (client == null) return;
  │ ^^^^^
  ╵
[SEVERE] chopper_generator on lib/api/mg_qa.swagger.dart:

Could not format because the source could not be parsed:

line 3, column 1 of .: This requires the 'class-modifiers' language feature to be enabled.
  ╷
3 │ final class _$MgQa extends MgQa {_$MgQa([ChopperClient? client]) { if (client == null) return;
  │ ^^^^^
  ╵
[SEVERE] chopper_generator on lib/api/mg_dev.swagger.dart:

Could not format because the source could not be parsed:

line 3, column 1 of .: This requires the 'class-modifiers' language feature to be enabled.
  ╷
3 │ final class _$MgDev extends MgDev {_$MgDev([ChopperClient? client]) { if (client == null) return;
  │ ^^^^^
  ╵
[SEVERE] chopper_generator on lib/api/dp_dev.swagger.dart:

Could not format because the source could not be parsed:

line 3, column 1 of .: This requires the 'class-modifiers' language feature to be enabled.
  ╷
3 │ final class _$DpDev extends DpDev {_$DpDev([ChopperClient? client]) { if (client == null) return;
  │ ^^^^^
  ╵
[SEVERE] chopper_generator on lib/api/dp_qa.swagger.dart:

Could not format because the source could not be parsed:

line 3, column 1 of .: This requires the 'class-modifiers' language feature to be enabled.
  ╷
3 │ final class _$DpQa extends DpQa {_$DpQa([ChopperClient? client]) { if (client == null) return;
  │ ^^^^^
  ╵
[INFO] Running build completed, took 2m 31s
[INFO] Caching finalized dependency graph completed, took 208ms
[SEVERE] Failed after 2m 31s`
this is the build.yaml: 
`targets:
  $default:
    builders:
      swagger_dart_code_generator:
        options:
          input_folder: "lib/swaggers/"
          output_folder: "lib/api/"
          separate_models: true
          with_base_url: false
          input_urls:
            - url: "https://api-dev.xxxxx.com/api-yaml"
              file_name: "mg-dev.yaml"
            - url: "https://api-dp-dev.xxxxx.com/api-yaml"
              file_name: "dp-dev.yaml"
            - url: "https://api-qa.xxxxxcom/api-yaml"
              file_name: "mg-qa.yaml"
            - url: "https://api-dp-qa.xxxxx.com/api-yaml"
              file_name: "dp-qa.yaml"
            - url: "https://api-prod.xxxxx.com/api-yaml"
              file_name: "mg-prod.yaml"
            - url: "https://api-dp-prod.xxxxx.com/api-yaml"
              file_name: "dp-prod.yaml"
morofir commented 4 months ago

this is one of the generated files:

part 'dp_qa.swagger.chopper.dart';

// **************************************************************************
// SwaggerChopperGenerator
// **************************************************************************

@ChopperApi()
abstract class DpQa extends ChopperService {
  static DpQa create({
    ChopperClient? client,
    http.Client? httpClient,
    Authenticator? authenticator,
    ErrorConverter? errorConverter,
    Converter? converter,
    Uri? baseUrl,
    Iterable<dynamic>? interceptors,
  }) {
    if (client != null) {
      return _$DpQa(client);
    }

    final newClient = ChopperClient(
        services: [_$DpQa()],
        converter: converter ?? $JsonSerializableConverter(),
        interceptors: interceptors ?? [],
        client: httpClient,
        authenticator: authenticator,
        errorConverter: errorConverter,
        baseUrl: baseUrl);
    return _$DpQa(newClient);
  }