swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

Please support null-safety on Dart generator

Open puelocesar opened this issue 4 years ago • 3 comments

Description

Dart 2.13 added null-safety to the language, and swagger-codegen generator is not compatible with it, generating a code that won't compile.

Reference: https://dart.dev/null-safety

Swagger-codegen version

3.0.30

Command line used for generation

swagger-codegen generate -i https://$MY_API/api/swagger.json -l dart

Suggest a fix/enhancement

https://dart.dev/null-safety

puelocesar avatar Dec 10 '21 11:12 puelocesar

插眼

lfun125 avatar Dec 26 '21 03:12 lfun125

+1 Its not optional since the introduction of null safety - null used when the type is non-nullable throws an exception. Any null attribute used in a model's constructor will fail unless the class attribute (of type T) is declared nullable (as T?). This is a severe limitation.

A quick fix might be to use nullable type everywhere.

allComputableThings avatar Apr 21 '24 23:04 allComputableThings

The current release of https://github.com/OpenAPITools/openapi-generator seems to work for null-safe Dart, if you're in a hurry.

allComputableThings avatar Apr 22 '24 02:04 allComputableThings