Skip to content

Generator Crashes with Unhelpful Error Message #202

@garricklw

Description

@garricklw

Is your issue related to the code that was generated?

No, my issue is with the openapi-generator-dart wrapper/config

Description of the bug

Using version 6.1.0.

My experience with previous versions was that if you had something in the yaml the generator didn't like, it would still generate the code, but the code would have bugs. While this was still frustrating (especially when the open API is valid), it's preferred to what it does now, which is crash with an error message that tells me nothing about what it doesn't like about the yaml.

So far I've gotten the following error message:

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

ProcessException: The directory name is invalid (at ../../runtime/bin/process_win.cc:577)
Command: cmd.exe /c flutter pub get

For all of the following cases:

  • didn't like the contentMediaType key
  • didn't like a tuple as a return type on a route
  • one other issue I'm currently trying to debug.

The only way I have to figure out what the actual issue is is to just trial and error by slowly adding pieces into the yaml, which is really tedious.

Steps to reproduce

dart run build_runner build --delete-conflicting-outputs --verbose

Minimal openapi specification

openapi.yaml

Annotation used

@openapi(
additionalProperties: AdditionalProperties(
pubName: "rfts_backend_api",
pubAuthor: 'Garrick White',
pubAuthorEmail: 'garrickw@percsolutions.com',
pubHomepage:
'',
),
// run dart run build_runner build --delete-conflicting-outputs to regenerate sdk
inputSpec: InputSpec(path: "lib/openapi.yaml"),
generatorName: Generator.dart,
outputDirectory: 'lib/api',
)

Expected behavior

Best case scenario, I'd like the error message to tell me where in the yaml it's having problems.

Otherwise it would be fine to generate code with errors and I can infer which part of the yaml it didn't like.

Logs


Screenshots

No response

Platform

Linux

Library version

6.1.0

Flutter version

3.41.7

Flutter channel

stable

Additional context


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions