Is there a way to transfer swagger from json to yaml in AutoRest?
Hi AutoRest team,
In AutoRest, is there any way to transfer swagger from json to yaml? We can deserialize from json and serialize to yaml, but just wonder whether AutoRest has the ability, our tool depends on AutoRest already. Thanks!!
Hi @hellosnow, try --output-artifact=swagger-document.yaml. However, this will emit a fully resolved (if your Swagger contains external references) and merged (if you have multiple input-files) Swagger. Hopefully this is helpful, now that I think about it, we should probably also add an "ouput-artfact" that will spit out the original files individually (but transcoded to YAML/JSON)
Wow great! Fully resolved swagger contains external references is expected by us.
Does output-artifact option only available in new CLI? I tried autorest -FANCY -g SwaggerResolver -i advisor.json --output-artifact=advisor.yaml and it hint me to use new CLI.
Or please help to correct the syntax if I'm wrong, thanks!
yes, this is only available in the new CLI, i.e. in your case:
autorest --input-file=advisor.json --output-artifact=swagger-document.yaml
@olydis wow cool I can generate the yaml files from swagger now, thanks!
@hellosnow Nice! Note that I had a typo in my command: output-artifact must be swagger-document.yaml and not advisor.yaml, this is about the type of thing to be emitted and advisor.yaml is nothing AutoRest recognizes as a type of thing to emit.
I'll close this issue but feel free to post further questions in here or reopen if it doesn't work for you!
@olydis interesting that I can generate the advisor.yaml via autorest --input-file=D:\Code\azure-rest-api-specs\specification\advisor\resource-manager\Microsoft.Advisor\2017-04-19\advisor.json --output-artifact=advisor.yaml, where the output-artifact could be any name?
@hellosnow Are you saying you can generate the resolved YAML with autorest --input-file=D:\Code\azure-rest-api-specs\specification\advisor\resource-manager\Microsoft.Advisor\2017-04-19\advisor.json --output-artifact=advisor.yaml, even if output-artifact is any name? Not sure if this is a question or a statement.