Swagger XML attribute and content definition

自古美人都是妖i 提交于 2019-12-01 21:57:20

问题


I would like to describe the XML response payload of a RESTful interface with swagger. However, I struggle describing a particular XML tag in the swagger data model.

I can't get swagger ui to create an appropriate example XML tag in this form, with an attribute and content between the opening and closing XML tags:

<Person id="bar">foo</Person>

The documentation (here) only describes how to model a tag with sub tags (type: object) or a tag with content (type: string), but not both at the same time.

I tried this, which the swagger-editor accepts without any errors or warnings:

definitions:
  Person:
    type: string
    example: foo
    properties:
      id:
        type: string
        example: bar
        xml:
          attribute: true

but it will be rendered by swagger-ui to the following example:

<Person id="bar"></Person>

As you can see, no "foo" content in there.

Thanks in advance for any helpful hints!


回答1:


Unfortunately there's no way to represent that using the OpenAPI Specification 2.0.

This issue is being tracked here and could be addressed in future versions of the specification.



来源:https://stackoverflow.com/questions/42023864/swagger-xml-attribute-and-content-definition

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