最近,我需要从持久类和序列类生成一个 Swagger 规范,所以我发布了我的代码(它并不完整 - 你仍然需要处理应用程序的细节,但这是一个开始)。 代码[在这里](https://github.com/eduard93/Utils/blob/master/Utils/YAML.cls.xml)。 假设你有下面的类:
 
你可以通过以下代码自动生成此 Swagger 定义: REST.Test.Person: type: "object" properties: Age: type: "integer" DOB: type: "string" FavoriteColors: type: "array" items: type: "string" FavoriteNumbers: type: "object" Home: $ref: "#/definitions/REST.Test.Address" Name: type: "string" Office: $ref: "#/definitions/REST.Test.Address" SSN: type: "string" Spouse: $ref: "#/definitions/REST.Test.Person" REST.Test.Address: type: "object" properties: City: type: "string" State: type: "string" Street: type: "string" Zip: type: "string" 主方法:Utils.YAML:GenerateClasses 测试运行:do ##class(Utils.YAML).Test()