【问题标题】:OpenApi Generator create models with type String instead of DateOpenApi Generator 创建类型为 String 而不是 Date 的模型
【发布时间】:2020-10-21 08:32:21
【问题描述】:

我正在使用OpenApi Generator 为我的 Angular 项目创建服务和模型。

这是我的 Json 示例:

"uploadDate" : {
              "type" : "string",
              "description" : "Data caricamento",
              "format" : "date-time"
            },

当我生成文件时,uploadDate 被转换为字符串而不是日期。

见:

     /**
     * Data caricamento
     */
    uploadDate?: string;

有没有办法添加配置并使用 Date 作为格式为日期时间的类型创建模型?

这是我用来启动生成的脚本:

"generate": "openapi-generator-cli generate -g typescript-angular -i openapi.json -o ./generated-sources/client"

【问题讨论】:

    标签: angular typescript openapi openapi-generator


    【解决方案1】:

    通过添加修复:--type-mappings=DateTime=Date

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-20
      • 1970-01-01
      • 2023-04-02
      • 2021-02-05
      • 2020-03-16
      • 2020-12-04
      • 1970-01-01
      相关资源
      最近更新 更多