PersistentクラスやSerialクラスからSwaggerクラスを生成する
先日、永続クラスとシリアルクラスからSwagger仕様を生成する必要がありました。そこで、その時のコードを公開することにします(完全なコードではないため、アプリケーション固有の部分を変更する必要がありますが、まずは出発点として使用できます)。 こちらからご利用ください。
次のクラスがあるとしましょう。
クラス
この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()
@Eduard Lebedyukさんが書いた元の記事へ