Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator fails on YAML with no defined schemas #8

Open
ynnob opened this issue Nov 27, 2022 · 1 comment
Open

Generator fails on YAML with no defined schemas #8

ynnob opened this issue Nov 27, 2022 · 1 comment

Comments

@ynnob
Copy link
Contributor

ynnob commented Nov 27, 2022

Hey this is just a little bug i found that is not really important but it could confuse some people if they just test a generation with an basic yaml file.

If there is no schema defined in the components section, the generator fails beacuse your generation script is missing some null checks at openapi_code_builder line 150:

    for (final schemaEntry in api.components!.schemas!.entries) {
      _schemaReference(schemaEntry.key, schemaEntry.value!);
    }
    if (api.components!.securitySchemes != null && !ignoreSecuritySchemes) {
      for (final securityScheme in api.components!.securitySchemes!.entries) {
        _securitySchemeReference(securityScheme.key, securityScheme.value!);
      }
    }

I think components and api.components!.schemas should be null checked there. There is a chance that line 153 will also fail if yo security scheme is defined in the yaml but i cant confitm atm.

Following this the generator should not generate the *.g.dart file and has to remove the part '*.g.dart'; link in the api file.

@ynnob
Copy link
Contributor Author

ynnob commented Nov 27, 2022

can't fix myself atm because i would have to dig deeper to understand all the genration stuff that depends on this change of not generating a *.g.dart file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant