ChrisLaurie
4 years agoVisitor
Empty object in response in Swagger ui
I get see this in the response in the ui:
I was expecting the layout of RETURN inside the object and not just a pair of curly braces. My swagger YAML is:
openapi: '3.0.1'
info:
title: Sample swagger
version: '1.0'
description: Test
servers:
- url: https://test.yourcompany.com/v1/test
paths:
/test:
post:
requestBody:
description: 'Passed in parameters for: test'
content:
application/json:
schema:
$ref: '#/components/schemas/RequestBody'
responses:
'200':
description: 'Success'
content:
application/json:
schema:
$ref: '#/components/schemas/ResponseBody'
components:
schemas:
RequestBody:
type: object
description: 'The JSON to be submitted with the request.'
properties:
MAXROWS:
type: integer
maxLength: 4
description: 'Maximum number of customers'
ResponseBody:
type: object
description: 'The JSON returned by the api.'
properties:
RETURN:
type: object
items:
$ref: '#/components/schemas/RETURN'
ADDRESSDATA:
type: array
items:
$ref: '#/components/schemas/ADDRESSDATA'
RETURN:
description: 'Test return'
properties:
TYPE:
type: string
maxLength: 1
description: 'Message type: S Success- E Error- W Warning- I Info- A Abort'
ID:
type: string
maxLength: 20
description: 'Message Class'
NUMBER:
type: string
maxLength: 3
description: 'Message Number'
MESSAGE:
type: string
maxLength: 220
description: 'Message Text'
ADDRESSDATA:
description: 'Test Adress Data'
properties:
CUSTOMER:
type: string
maxLength: 10
description: 'Customer Number'
NAME:
type: string
maxLength: 40
description: 'Name 1'
COUNTRY:
type: string
maxLength: 3
description: 'Country Key'
CITY:
type: string
maxLength: 40
description: 'City'
POSTL_COD1:
type: string
maxLength: 10
description: 'City postal code'
REGION:
type: string
maxLength: 3
description: 'Region (State- Province- County)'
STREET:
type: string
maxLength: 60
description: 'Street'
TEL1_NUMBR:
type: string
maxLength: 30
description: 'First telephone no.: dialling code+number'
ADDRESS:
type: string
maxLength: 10
description: 'Address'
Hi Chris,
Change the schemas as follows:
components: schemas: ... ResponseBody: type: object description: 'The JSON returned by the api.' properties: RETURN: $ref: '#/components/schemas/RETURN' # <------------ ADDRESSDATA: type: array items: $ref: '#/components/schemas/ADDRESSDATA' RETURN: description: 'Test return' type: object # <------------ properties: ...