#swagger #openapi
Вопрос:
я пытаюсь создать массив объектов со следующим путем:
paths:
/book/:
get:
tags:
- "Help"
summary: "show my book"
produces:
- "application/xml"
- "application/json"
parameters: []
responses:
"200":
description: "successful operation"
schema:
type: "array"
xml:
name: Book
items:
$ref: "#/definitions/Book"
"400":
description: "Invalid status value"
x-swagger-router-controller: "swagger_server.controllers.book_controller"
и следующие определения:
definitions:
BookAuthor:
type: object
properties:
Author:
type: string
Bio:
type: string
xml:
attribute: true
xml:
name: Author
Book:
type: object
properties:
Title:
type: string
Description:
type: "string"
BookAuthors:
type: array
items:
$ref: "#/definitions/BookAuthor"
xml:
name: BookAuthors
wrapped: true
xml:
name: "MyBook"
example:
Title: "Name of the book"
description: "Book Description"
BookAuthors: [["Author 1", "Author 1 Bio"], ["Author 2", "Author 2 Bio"]]
В xml-файле отсутствуют теги автора, которые отображаются в виде индексов (0,1), вот что я получаю:
<?xml version="1.0" encoding="UTF-8"?>
<MyBook>
<Title>Name of the book</Title>
<description>Book Description</description>
<BookAuthors>
<Author>
<0>Author 1</0> <--- Here showing <0> instead of <Author>
<1>Author 1 Bio</1> <--- Here showing <1> instead of <Bio>
</Author>
<Author>
<0>Author 2</0>
<1>Author 2 Bio</1>
</Author>
</BookAuthors>
</MyBook>
How can i get the <Author></Author> amp; <Bio></Bio>
to be displayed?