swagger-typescript-codegen
swagger-typescript-codegen copied to clipboard
YAML-Support
Hey there, for libraries like https://www.npmjs.com/package/swagger-typescript-codegen it would be nice, if your tool could generate a Typescript file, out of a YAML file.
Hey @DenisSabo!
Do you mean using YAML files for specifying the Swagger spec (similar to the current Swagger JSON file)?
Thanks for the input!
Hey @mtennoe,
yes that's what I meant. The reason for the suggestion is that for me it would mean one less step in my toolchain.
Thank you for the fast response! 👍
It would add some complexity to the whole pipeline, but if we do it correctly we can hide a lot of the complexity. I guess there are some nice tools out there for parsing and reading the YAML and convert it to the internal format in the codegen tool as well. Don't really have the time to look into that in the nearest future myself though. But you are free to give it a go if you want to :)
Out of scope IMHO.
@DenisSabo you could convert from YAML to JSON as a preprocessing step, e.g. https://stackoverflow.com/questions/34733253/converting-a-swagger-yaml-file-to-json-from-the-command-line
with npm install --save js-yaml
you can change the line in the example usage:
var swagger = JSON.parse(fs.readFileSync(file, "UTF-8"));
by
var yaml = require('js-yaml');
var swagger = yaml.safeLoad(fs.readFileSync(file, 'utf8'));
IMHO, there is no need for adding the yaml
dependency... mh, maybe for the CLI tool...