represent a xml on Swagger yaml

99封情书 提交于 2019-12-20 07:14:13

问题


I'm making a document on swagger editor, but I don't know how solve that..

What do I need to write in a YAML file to get this result?

<tag>
    <example Amount='100.00' NumberOfGuests='1'/>
    <example Amount='120.00' NumberOfGuests='2'/>
    <example Amount='140.00' NumberOfGuests='3'/>
</tag>

I tried to write "example" multiple times but an error appears:

(YAML Syntax Error Duplicated mapping key at line 621)

What do I need to do to represent the same tag multiple times with different values on the same attributes?


回答1:


I believe you'd do it like this:

definitions:
  Tag:
    xml:
      # use `tag` instead of `Tag` as the name
      name: tag
    properties:
      example:
        type: array
        items:
          $ref: '#/definitions/Example'
        xml:
          # don't wrap array
          wrapped: false
  Example:
    type: object
    properties:
      Amount:
        type: number
        format: float
        xml:
          # it's an attribute, not an element
          attribute: true
      NumberOfGuests:
        type: integer
        format: int32
        xml:
          attribute: true

Note the xml attributes to tell how to format the XML specific payload in JSON Schema. More on that structure is found here.



来源:https://stackoverflow.com/questions/40140385/represent-a-xml-on-swagger-yaml

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