Daniel3
4 years agoOccasional Visitor
Swagger multiple Schemas in one response
openapi: 3.0.0
info:
version: '1.0'
title: Receipt API
description: the ultimate receipt API
servers:
# Added by API Auto Mocking Plugin
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/d.martins/receipts/1.0
paths:
/receipts/:
post:
tags:
- Receipts
requestBody:
$ref: '#/components/requestBodies/Items'
responses:
201:
description: Created
components:
requestBodies:
Items:
content:
'application/json':
schema:
$ref: '#/components/schemas/Items'
Merchant:
content:
'application/json':
schema:
$ref: '#/components/schemas/Merchant'
schemas:
Items:
type: object
properties:
product:
type: integer
example: Bananas
product category:
type: integer
example: Healthy fruit
ean:
type: string
example: 1234567891012
price:
type: number
example: 19,99€
discount:
type: string
example: 15%
discount value:
type: number
example: 2,98€
Merchant:
type: object
properties:
merchant id:
type: number
example: 12345
store id:
type: string
example: ABC123456789
cashier:
type: string
example: Max Muster
Receipt_properties:
type: object
properties:
Receipt id:
type: string
example: ABC123456789123456789
transaction date and time:
type: string
example: 2021-05-05T11:11:11.123Z
format: date-time
Hey everyone,
i am new to coding and try to learn how to create an api by writing one that should transfer receipt data.
i managed to create Schemas to have a nice overview of all values.
However i only manage to get one schema into my Post response, whatever i try i just run into error which is quite frustrating.
I am Happy for any help!
attached is the code: