无法从 openapi-generator mustache 模板引用供应商扩展

Rod*_*eas 3 openapi-generator

我有一个 Open API 3 规范的 yaml 文件,它有一些 x- 前缀的属性。我正在尝试使用 openapi-generator-cli 生成一个 Angular Typescript SDK。但是,当我在模板胡子中引用该属性时,以 x 为前缀的属性始终为空。

来自 yaml 的示例端点(省略了不相关的内容):

/about:
  get:
    summary: Information about this API
    x-foo: getAbout
Run Code Online (Sandbox Code Playgroud)

我如何在 Mustache 模板中使用它(省略了不相关的内容):

{{#operation}}
  public {{x-foo}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
Run Code Online (Sandbox Code Playgroud)

(基本上,我正在尝试使用 x-foo 参数作为正在生成的 SDK 中的方法名称。)

但是,生成的 SDK 替换{{x-foo}}为空白:

public ()
Run Code Online (Sandbox Code Playgroud)

这就是我调用生成器的方式(没有换行符):

openapi-generator generate 
    --generator-name typescript-angular 
    --template-dir ./path/to/templates 
    --input-spec ./path/to/api.yml 
    --output ./output 
    --config ./path/to/config.json
Run Code Online (Sandbox Code Playgroud)

如何从 openapi-generator 模板中引用供应商扩展/以 x 为前缀的 Open API 3 属性?

Rod*_*eas 6

供应商扩展在vendorExtensions父属性内可用,而不是直接可用。

因此,x-foo要从 mustache 模板访问属性,上面的示例将是:

{{#operation}}
  public {{vendorExtensions.x-foo}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
Run Code Online (Sandbox Code Playgroud)

要查看您正在处理的对象(例如 api 规范 yml 或 json 的解析版本),请运行带有-v标志的 generate 命令。将打印出来的众多内容之一是解析后的规范。