gibahjoe / openapi-generator-dart

Openapi Generator for Dart/Flutter
BSD 3-Clause "New" or "Revised" License
112 stars 29 forks source link

Dio generator error: Expected an identifier #120

Closed jdk-21 closed 5 months ago

jdk-21 commented 6 months ago

Description of the bug

I'm trying to generate the Jellyfin openapi spec with dio. The http-generator seems to work fine. The normal code generation works, but when the build_runner runs inside the generated api, it fails with following errors:

[INFO] Precompiling build script... completed, took 3.3s
[INFO] Building new asset graph completed, took 486ms
[INFO] Checking for unexpected pre-existing outputs. completed, took 0ms
[INFO] Generating SDK summary completed, took 2.5s
[SEVERE] built_value_generator:built_value on lib/src/model/transcoding_profile.dart:

This builder requires Dart inputs without syntax errors.
However, package:openapi/src/model/transcoding_profile.dart (or an existing part) contains the following errors.
transcoding_profile.dart:96:35: Expected an identifier.
transcoding_profile.dart:98:25: Expected an identifier.

Try fixing the errors and re-running the build.

[INFO] Running build completed, took 17.0s
[INFO] Caching finalized dependency graph completed, took 260ms
[SEVERE] Failed after 17.2s

transcoding_profile.dart:

@BuiltValueHook(initializeBuilder: true)
  static void _defaults(TranscodingProfileBuilder b) => b
      ..estimateContentLength = false
      ..enableMpegtsM2TsMode = false
      ..transcodeSeekInfo = const ._(TranscodeSeekInfo.auto) // Error
      ..copyTimestamps = false
      ..context = const ._(EncodingContext.streaming) // Error
      ..enableSubtitlesInManifest = false
      ..minSegments = 0
      ..segmentLength = 0
      ..breakOnNonKeyFrames = false;

I tried generating with the cli and the annotation:

openapi-generator generate -i ../jellyfin-openapi-stable.json  -g dart-dio
@Openapi(
    additionalProperties:
        DioProperties(pubName: 'jellyfin_api', pubAuthor: 'Johnny dep'),
    inputSpecFile: 'jellyfin-openapi-stable.json',
    generatorName: Generator.dio,
    outputDirectory: 'api/jellyfin_api',
    alwaysRun: true)
class Example {
}

Steps to reproduce

Download the OpenAPI spec from https://api.jellyfin.org Run the code generation via CLI or Annotations

Expected behavior

No error

Logs

No response

Screenshots

No response

Platform

macOS

Library version

4.13.1

Flutter version

3.16

Flutter channel

stable

Additional context

No response

gibahjoe commented 5 months ago

Hi, I know this has been a while but here is something that might help. Basically, you either update the spec or update the code.

Since this library is a wrapper around the openapi-generator, you might want to open an issue there.