bcherny / json-schema-to-typescript

Compile JSON Schema to TypeScript type declarations
https://bcherny.github.io/json-schema-to-typescript-browser/
MIT License
2.92k stars 392 forks source link

feat: [#631] implemented refOptions CLI argument #632

Open ndopj opened 3 weeks ago

ndopj commented 3 weeks ago

resolves: https://github.com/bcherny/json-schema-to-typescript/issues/631

Current changes accept $refOptions argument as JSON string from command line.

Those options are then being merged with default value for $refOptions. Even if current default value {} would be changed in the future, fields from command line argument --refOptions won't influence "not overridden" $refOption fields.

Command line argument --refOptions cannot use 1:1 naming with Options interface field $refOptions because it contains $ character which might cause issues (on some Shells), if the command line arguments are not being enclosed as string ("").

Still need to figure out if its possible to create any meaningful tests for this !! Any help or feedback appreciated.

ndopj commented 3 weeks ago

@bcherny Could I kindly ask for a review ? Don't know anybody amongst contributors so tagging you as an active one. I hope its not rude to you, in that case I am sorry :no_mouth:

Also if test should be included for this CLI option - I am not sure whether this would fit testCLI.ts structure. If I understand it correctly, tests are implemented via snapshots meaning it's asserted that output of each tested operation is same ? However, in such case, it would not be possible to include scenario described in the linked issue. I am correct ?