9

I would like to describe the XML response payload of a RESTful interface with OpenAPI 2.0 (Swagger 2.0). However, I struggle describing a particular XML tag in the OpenAPI 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.

4

1 回答 1

7

不幸的是,没有办法使用OpenAPI 规范 2.0、3.0或 3.1来表示它

此处正在跟踪此问题,并且可以在规范的未来版本中解决。

于 2017-02-06T10:47:41.850 回答