glideapps / quicktype

Generate types and converters from JSON, Schema, and GraphQL
https://app.quicktype.io
Apache License 2.0
11.93k stars 1.05k forks source link

Update Dart Model Generation Command to Support Optional Fields #2471

Open bhanuka96 opened 7 months ago

bhanuka96 commented 7 months ago

I have been using the following command to generate Dart model classes locally:

npm start -- "--lang dart --null-safety --final-props --copy-with -o jsons/sample.dart jsons/sample.json"

While the command works well, I noticed that all generated fields are marked as required, even when I haven't explicitly specified them as required arguments.

Expected Behavior: The command should generate Dart model classes with optional fields for those properties that are not marked as required in the JSON schema.

inferrinizzard commented 3 months ago

Hi @bhanuka96 , could you help to provide an example of your input and output as well as the expected output ?