首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在单个架构中引用多个架构

在单个架构中引用多个架构
EN

Stack Overflow用户
提问于 2019-01-10 19:11:02
回答 1查看 251关注 0票数 1

在swaggerhub中,我正在尝试构建一个restful API。为此,我已经为请求创建了n个POJO。我想将它们表示为其他POJO示例中的引用:

代码语言:javascript
运行
复制
 ClientInformation:
   type: object
   schema:
     $ref: '#/definitions/EditClient'
     $ref: '#/definitions/OtherDetails' #Duplicate mapping key error I see at this line
    properties:
      notes:
      type: string
      example: This is a test
      description: A description

我尝试过,,但不起作用。敬请指教。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-12 05:41:22

如果ClientInformationEditClientOtherDetails模式的合并,则需要allOf

代码语言:javascript
运行
复制
ClientInformation:
  allOf:
    - $ref: '#/definitions/EditClient'
    - $ref: '#/definitions/OtherDetails'
    - type: object
      properties:
        notes:
          type: string
          example: This is a test
          description: A description

如果ClientInformation的属性是其他模式的实例,则可以按如下方式对属性模式执行$ref操作:

代码语言:javascript
运行
复制
ClientInformation:
  type: object
  properties:
    notes:
      type: string
      example: This is a test
      description: A description
    foo:
      $ref: '#/definitions/EditClient'
    bar:
      $ref: '#/definitions/OtherDetails'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54127422

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档