从YAML生成javascript类/对象

从YAML生成javascript类/对象,javascript,yaml,generator,code-generation,swagger,Javascript,Yaml,Generator,Code Generation,Swagger,是否有任何工具可以从YAML生成JavaScript类 我有一个大摇大摆的YAML,我想生成如下所示的javascript模型: 'use strict'; function Product(name,description){ this.name = name; this.description = description; this.toString = function(){ return this.name+" : "+this.descript

是否有任何工具可以从YAML生成JavaScript类

我有一个大摇大摆的YAML,我想生成如下所示的javascript模型:

'use strict';

function Product(name,description){
    this.name = name;
    this.description = description;
    this.toString = function(){
        return this.name+" : "+this.description;
}
}

使用昂首阔步的YAML:

.
.
.
definitions:
  product:
properties:
  name:
    type: string
  description:
    type: string
required:
  - name
  - description
.
.
.
您可以使用生成JSAPI客户端(带有模型)、其他语言的客户端(例如Ruby、Typescript等)、服务器存根(例如NodeJS、JavaSpring等)和API文档

鉴于您已经拥有OpenAPI/Swagger规范,您可以执行以下操作:

  • 选择顶部菜单中的“文件”,然后选择“导入文件”加载等级库
  • 然后在顶部菜单中选择“Generate Client”并单击“Javascript”

  • 是的,事实上,我已经尝试过这个和angular生成的代码,但是我不知道如何使用生成的代码,我没有找到教程,也没有找到我前面问题的答案