OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
I'm trying to produce null-safe api code from swagger json docs so we can upgrade Dart to 2.17. I understood from the docs that the newest version should produce null safe api code and models, but it doesn't look null safe to me.
Description
I'm trying to produce null-safe api code from swagger json docs so we can upgrade Dart to 2.17. I understood from the docs that the newest version should produce null safe api code and models, but it doesn't look null safe to me.
openapi-generator version
openapi_generator_annotations: ^3.3.0 openapi_generator_cli: 3.0.0-nullsafety.1
Not a regression
OpenAPI declaration file content or url
mv ../lib/generated/asn/lib/* ../lib/generated/asn rm -r ../lib/generated/asn/.openapi-generator rm -r ../lib/generated/asn/.openapi-generator-ignore rm -r ../lib/generated/asn/.travis.yml rm -r ../lib/generated/asn/pubspec.yaml rm -r ../lib/generated/asn/git_push.sh rm -r ../lib/generated/asn/README.md rm -r ../lib/generated/asn/.gitignore rm -r ../lib/generated/asn/lib
Input is a basic swagger doc
Portion of output:
part of openapi.api;
class AsnOrder { /// Returns a new [AsnOrder] instance. AsnOrder({ this.asnId, this.asnOrderId, this.asnOrderLine = const [], this.createDateTime, this.createdId, this.dcNumber, this.lastUpdatedTime, this.masterShippingNumber, this.modifiedId, this.modifiedSource, this.poVendor, this.thdPo, this.workOrderNumber, });
String asnId;
String asnOrderId;
List asnOrderLine;
DateTime createDateTime;
String createdId;
String dcNumber;
DateTime lastUpdatedTime;
Generation Details
Script code to invoke api generation:
Asn Core
openapi-generator generate -i ./swagger-docs/asn.json -t ./templates/ -o ../lib/generated/asn -g dart --skip-validate-spec -c ./config/asn-config.json \ --global-property modelTests=false,modelDocs=false,apiTests=false,apiDocs=false
Steps to reproduce
Related issues/PRs
Suggest a fix
Shouldn't my code produce a null check on each variable?
Not
String asnId;
as the script is producing now butString? asnId
orString asnId = ''