MatthiasMargot / typegen

Generate source-code types from a swagger-specification file
MIT License
1 stars 1 forks source link

Restore support for yaml files #17

Open MatthiasMargot opened 3 years ago

MatthiasMargot commented 3 years ago

There's a dependency specified for this project called "swagger-parser" that's currently not used. It was introduced to support yaml as the input format for source-files that typegen should parse. Currently typegen only supports json format.

Support for yaml should be added, some options for API implementation:

  1. add an optional "type" / "extension" flag to the CLI defaulting to json
  2. figure out the file-type based on its contents, for this case it should be fine to assume a limitation to only json/yaml
  3. figure out the file-type based on the extension provided in the input & output file-path arguments (this is un-desirable since it forces the user to specify file extensions in the argument, that shouldn't be necessary)
boobo94 commented 3 years ago

I vote for the 3rd option for the input part.

boobo94 commented 3 years ago

Is not clear what are you referring to about the output in the 3rd bullet point.

MatthiasMargot commented 3 years ago

So, for option 3 here, I mean that it would be possible to decide whether the input is yarn or json based on the file extension e.g.:

typegen input.json output.ts

vs

typegen input output

Here in the 2nd example command that would not be possible since the two path arguments are provided without extensions so the 2nd case here would result in an un-supported usage of the API. I think the 2nd case should work so I'm not too much in favor of option 3 but we'll have to see what's possible.