问题
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