Skip to content

Instantly share code, notes, and snippets.

@gunzip
Last active October 1, 2025 20:51
Show Gist options
  • Save gunzip/6f42c323ba2b7b099a8fd0a0fcfef9ca to your computer and use it in GitHub Desktop.
Save gunzip/6f42c323ba2b7b099a8fd0a0fcfef9ca to your computer and use it in GitHub Desktop.
openapi: 3.0.1
info:
title: Yeah
description: Foobar
version: "1.0.0"
servers:
- url: https://example.com
paths:
/foo:
post:
operationId: foo-post
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SomeSchema"
application/xml:
schema:
$ref: "#/components/schemas/SomeOtherSchema"
required: true
responses:
"201":
description: "201"
content:
application/json:
schema:
$ref: "#/components/schemas/SomeSchema"
application/xml:
schema:
$ref: "#/components/schemas/SomeOtherSchema"
"200":
description: "200"
content:
application/json:
schema:
$ref: "#/components/schemas/SomeSchema"
application/xml:
schema:
$ref: "#/components/schemas/SomeOtherSchema"
"5XX":
description: "5XX"
content:
application/json:
schema:
$ref: "#/components/schemas/SomeSchema"
application/xml:
schema:
$ref: "#/components/schemas/SomeOtherSchema"
"4XX":
description: "4XX"
content:
application/json:
schema:
$ref: "#/components/schemas/SomeSchema"
application/xml:
schema:
$ref: "#/components/schemas/SomeOtherSchema"
"404":
description: "Not found"
default:
description: "You do not have necessary permissions for the resource"
content:
application/json:
schema:
$ref: "#/components/schemas/SomeSchema"
components:
schemas:
SomeSchemaEnum:
type: string
enum:
- email
- phone
SomeSchemaBase:
properties:
type:
allOf:
- $ref: "#/components/schemas/SomeSchemaEnum"
value:
type: string
maxLength: 255
required:
- type
SomeSchema:
allOf:
- $ref: "#/components/schemas/SomeSchemaBase"
- type: object
properties:
schemas:
- $ref: "#/components/schemas/SomeSchema"
- type: object
required:
- value
SomeOtherSchema:
# yes, empty objects are valid
type: object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment