小编dig*_*le1的帖子

swagger-codegen 根据自定义属性描述添加注释

我正在尝试做类似以下的事情:

在我的架构 JSON 模型部分:

"MyObject": {
  "type": "object",
  "description": "my description",
  "properties": {
    "type": "string",
    "description": "my property description",
    "customAnnotation": "true"
  }
}
Run Code Online (Sandbox Code Playgroud)

因此,我一开始就尝试扩展 JSON Schema - 可能是我的第一个问题。但是,我不知道如何合法地做到这一点(如果可能的话)。

“customAnnotation”胡子模板的用例片段(-l spring):

{{#vars}}
{{^customAnnotation}}@CustomAnnotation {{/customAnnotation}}public {{{datatypeWithEnum}}} {{getter}}() {
    return {{name}};
}
{{/vars}}
Run Code Online (Sandbox Code Playgroud)

我真的可以做这样的事情吗?线索很有帮助(是的,我是这个领域的新手)!

注意:我还想使用找到的“customAnnotation”> 0 的计数来注释类。就像是:

{{^containsCustomAnnotations}}@ContainsCustomAnnotations {{/hasCustomAnnotation}}public void MyClass {
}
Run Code Online (Sandbox Code Playgroud)

谢谢!

jsonschema mustache swagger-codegen

5
推荐指数
1
解决办法
1853
查看次数

标签 统计

jsonschema ×1

mustache ×1

swagger-codegen ×1