Reputation: 416
Defining a swagger definition for an API specification using Open API 3.0.1. However,the response example GoodResponse defined here is not rendered. The syntax seems to be valid though. Any pointers as to what I'm doing wrong is appreciated
paths:
/java/api/play:
post:
tags:
- some-controller
operationId: someOperation
requestBody:
content:
application/xml:
schema:
$ref: '#/components/schemas/HarryKartType'
required: true
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
items:
$ref: '#/components/schemas/GoodResponse'
components:
schemas:
GoodResponse:
required:
- goodstatusCode
- goodresponseMessage
type: object
properties:
goodstatusCode:
type: integer
example: 200
goodresponseMessage:
type: array
example:
- position: 1
horseName: "TIMETOBELUCKY"
- position: 2
horseName: "HERCULES BOKO"
- position: 3
horseName: "CARGO DOOR"
items:
$ref: '#/components/schemas/GoodResponseMessage'
GoodResponseMessage:
type: object
properties:
position:
type: integer
example: 1
horseName:
type: string
example: "TIMETOBELUCKY"
Upvotes: 1
Views: 2063
Reputation: 348
You need to define $ref within the schema
, not within items
Try this:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/GoodResponse'
Upvotes: 2