Skip to content

Generator.dio causes error Error: 'NullThrownError' isn't a type. #170

Open
@isaac-merkos

Description

@isaac-merkos

Description of the bug

When I run dart run build_runner build --delete-conflicting-outputs on a project with this class

// Openapi Generator last run: : 2024-12-10T12:54:07.988426
import 'package:openapi_generator_annotations/openapi_generator_annotations.dart';

@Openapi(
    additionalProperties: AdditionalProperties(useEnumExtension: true, pubName: 'api_client'),
    inputSpec: RemoteSpec(path: 'http://localhost:3000/openapi.json'),
    generatorName: Generator.dio,
    skipIfSpecIsUnchanged: false,
    outputDirectory: 'api/api_client')
class Client {}

I get this error

[SEVERE] openapi_generator on lib/client.dart:
Failed to generate content.

Could not complete source generation Failed to generate source code. Build Command output: Failed to build build_runner:build_runner:
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/matcher-0.12.13/lib/src/error_matchers.dart:19:49: Error: 'CyclicInitializationError' isn't a type.
const isCyclicInitializationError = TypeMatcher<CyclicInitializationError>();
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/matcher-0.12.13/lib/src/error_matchers.dart:31:39: Error: 'NullThrownError' isn't a type.
const isNullThrownError = TypeMatcher<NullThrownError>();
                                      ^^^^^^^^^^^^^^^
 #0      OpenapiGenerator.runSourceGen (package:openapi_generator/src/openapi_generator_runner.dart:401:34)
<asynchronous suspension>
#1      OpenapiGenerator.generateSources.<anonymous closure> (package:openapi_generator/src/openapi_generator_runner.dart:346:7)
<asynchronous suspension>
#2      OpenapiGenerator.generateSources (package:openapi_generator/src/openapi_generator_runner.dart:345:12)
<asynchronous suspension>
#3      OpenapiGenerator.generatorV2 (package:openapi_generator/src/openapi_generator_runner.dart:195:7)
<asynchronous suspension>
#4      normalizeGeneratorOutput (package:source_gen/src/output_helpers.dart:10:1)
<asynchronous suspension>
#5      StreamCompleter.setSourceStream (package:async/src/stream_completer.dart:76:3)
<asynchronous suspension>

Steps to reproduce

I am not sure exactly how to reproduce it but every dependency is up to date

Minimal openapi specification

https://petstore3.swagger.io/api/v3/openapi.json

Annotation used

// Openapi Generator last run: : 2024-12-10T12:54:07.988426
import 'package:openapi_generator_annotations/openapi_generator_annotations.dart';

@openapi(
additionalProperties: AdditionalProperties(useEnumExtension: true, pubName: 'api_client'),
inputSpec: RemoteSpec(path: 'http://localhost:3000/openapi.json'),
generatorName: Generator.dio,
skipIfSpecIsUnchanged: false,
outputDirectory: 'api/api_client')
class Client {}

Expected behavior

I expected it to generate a client

Logs

No response

Screenshots

No response

Platform

Windows

Library version

6.0.0

Flutter version

3.24.4

Flutter channel

stable

Additional context

This only happens with `Generator.dio` and not with `Generator.dart` unfortunately I need dio

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions