【问题标题】:How to name a property using a reserved keyword in OpenApi/Swagger/YAML如何在 OpenApi/Swagger/YAML 中使用保留关键字命名属性
【发布时间】:2019-07-21 03:46:05
【问题描述】:

鉴于已经存在一个特殊的“类型”属性,它是一个保留关键字,有什么方法可以命名自定义属性“类型”。

components:  
  schemas:  
  element:  
  type: object 
  properties:  
    name:  
      type: string  #type here is the keyword
    type: #type here is the actual name of the property!
      type: string
        enum:
          - radiogroup
          - checkbox

无法修改生成 JSON 消息的后端系统以重命名属性。 谢谢。

【问题讨论】:

  • ps。原始 json 数据样本为:elements: [ { type: "radiogroup", name: "DentalQuestion2" } , { type: "checkbox", name: "DentalQuesiton3" } ]

标签: yaml swagger openapi surveyjs


【解决方案1】:

保留关键字可用作 OpenAPI 中的属性/参数名称。

您的示例的唯一问题是 YAML 缩进已关闭,除了您的对象和属性定义完全有效。

components:  
  schemas:  
    element:  
      type: object 
      properties:  
        name:  
          type: string
        type:   # <----- yes, property name can be "type"
          type: string
          enum:
            - radiogroup
            - checkbox

【讨论】:

  • 生成java代码时,如果已经定义了find类型方法
猜你喜欢
  • 1970-01-01
  • 2019-06-17
  • 2021-09-05
  • 1970-01-01
  • 2017-07-06
  • 1970-01-01
  • 2020-03-31
  • 2012-03-26
  • 1970-01-01
相关资源
最近更新 更多