Skip to content

Instantly share code, notes, and snippets.

@johannes-riecken
Created July 18, 2023 11:56
Show Gist options
  • Save johannes-riecken/963d48c1f19055733e5edf83c8b26625 to your computer and use it in GitHub Desktop.
Save johannes-riecken/963d48c1f19055733e5edf83c8b26625 to your computer and use it in GitHub Desktop.
components:
requestBodies:
Shape:
content:
application/json:
schema:
$ref: '#/components/schemas/Shape'
schemas:
Circle:
properties:
id:
type: integer
kind:
type: string
r:
type: integer
x:
type: integer
'y':
type: integer
type: object
Rectangle:
properties:
h:
type: integer
id:
type: integer
kind:
type: string
w:
type: integer
x:
type: integer
'y':
type: integer
type: object
Shape:
discriminator:
mapping:
Circle: '#/components/schemas/Circle'
CircleSpecial: '#/components/schemas/Circle'
Rectangle: '#/components/schemas/Rectangle'
propertyName: kind
example:
kind: circle
r: 3
x: 1
'y': 2
oneOf:
- $ref: '#/components/schemas/Circle'
- $ref: '#/components/schemas/Rectangle'
type: object
ShapeBase:
properties:
id:
type: integer
kind:
type: string
x:
type: integer
'y':
type: integer
required:
- kind
- x
- 'y'
type: object
info:
license:
name: MIT
url: https://www.example.com
title: foo
version: 0.0.1
openapi: 3.0.0
paths:
/circles:
get:
responses:
'200':
content:
application/json:
schema:
items:
$ref: '#/components/schemas/Shape'
type: array
description: successful operation
/rectangles:
get:
responses:
'200':
content:
application/json:
schema:
items:
$ref: '#/components/schemas/Shape'
type: array
description: successful operation
/shapes:
get:
responses:
'200':
content:
application/json:
schema:
items:
$ref: '#/components/schemas/Shape'
type: array
description: successful operation
post:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Shape'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Shape'
description: successful operation
'404':
description: shape not found
/shapes/{shapeId}:
get:
parameters:
- in: path
name: shapeId
required: true
schema:
type: integer
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Shape'
description: successful operation
'404':
description: shape not found
servers:
- url: http://localhost:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment