You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PostgreSQL与Swagger数据类型不兼容 可替换适配类型咨询

PostgreSQL与Swagger数据类型适配方案

Swagger(OpenAPI)采用JSON Schema类型体系,你提到的4种PostgreSQL字段对应适配规则如下:

  • id字段的PostgreSQL bigint 类型:Swagger中使用 integer 类型,补充format: int64属性标注即可适配。如果你的id数值超出JSON安全整数范围(2^53-1),建议额外备注要求前端以字符串形式传输避免精度丢失
  • name、location字段的PostgreSQL character varying 类型:Swagger中直接使用 string 类型适配,如需匹配PG字段的长度限制,可额外补充maxLength属性设置对应长度
  • price_range字段的PostgreSQL integer 类型:Swagger中使用 integer 类型,补充format: int32属性标注即可适配

适配示例(Swagger YAML格式)

components:
  schemas:
    Goods: # 替换为你的实际模型名
      type: object
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
          maxLength: 255 # 替换为你的varchar字段实际长度
        location:
          type: string
          maxLength: 500 # 替换为你的varchar字段实际长度
        price_range:
          type: integer
          format: int32

内容的提问来源于stack exchange,提问作者user15937825

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 02:36:03