我目前正在为现有API创建Swagger文档。该API具有POST接口,该接口的主体中需要一个XML文档,该文档如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<resource name="source"></resource>
<resource name="target"></resource>
</root>
我现在面临的问题是Swagger将把resource
都检测为重复键(这是正确的)。有没有办法使用XML文件中的重复键来招摇?
这是我的最小示例:
swagger: "2.0"
info:
title: "Example API"
description: "Just some MWE"
version: "1.0.0"
contact:
email: "something@example.com"
host: "localhost"
basePath: "/pets"
tags:
- name: "example"
description: "sample description"
schemes:
- "https"
paths:
/addPet:
post:
summary: ""
description: "Create a new Pet"
consumes:
- "application/xml"
parameters:
- in: "body"
name: "body"
schema:
$ref: '#/definitions/root'
responses:
200:
description: "OK"
400:
description: "Invalid ID"
404:
description: "Pet not found"
definitions:
root:
type: object
properties:
resource:
$ref: '#/definitions/resource1'
resource:
$ref: '#/definitions/resource2'
resource1:
type: object
properties:
name:
type: string
xml:
attribute: true
example: source
resource2:
type: object
properties:
name:
type: string
xml:
attribute: true
example: target