Generator fails on YAML with no defined schemas
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.
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.