Overloading description in Swagger file (YAML)

你离开我真会死。 提交于 2020-01-15 10:15:33

问题


I have an issue writing my swagger file. When I describe a parameter the description is overloaded by the description of the $ref of this same parameter (see the example bellow).

a-body:
    description: The body
    type: object
    properties:
      my_param:
        description: Full description 
        $ref: '#/definitions/reference'

definitions:
    reference:
        type: object
        required: [req]
        description: an http reference
        properties:
          req:
            type: string

The result: the description is overloaded

Can somebody help me get through this please ?


回答1:


$ref overwrites all of its sibling properties - it's how $ref works. You can try to work around this using something like:

my_param:
  description: Full description 
  allOf:
    - $ref: '#/definitions/reference'

This will work in Swagger Editor and Swagger UI.

There's also a feature request in the OpenAPI Specification repository to provide a better way to combine $ref with other properties.



来源:https://stackoverflow.com/questions/47155842/overloading-description-in-swagger-file-yaml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!