{
"openapi": "3.0.0",
"info": {
"title": "Simple API",
"version": "1.0.0",
"description": "A simple OpenAPI example"
},
"paths": {
"/hello/{name}": {
"get": {
"summary": "Say hello",
"parameters": [
{
"name": "name",
"in": "path",
"schema": {
"type": "string"
},
"description": "Name to greet"
},
{
"name": "language",
"in": "query",
"schema": {
"type": "string"
},
"description": "Language for the greeting",
"required": false
}
],
"responses": {
"200": {
"description": "A friendly greeting",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GreetingResponse"
}
}
}
}
}
}
},
"/ping": {
"get": {
"operationId": "ping",
"summary": "Ping operation",
"description": "A simple ping endpoint that does nothing.",
"responses": {
"200": {
"description": "Ping successful"
}
}
}
},
"/tree": {
"get": {
"summary": "Get a tree structure",
"responses": {
"200": {
"description": "A tree structure",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Tree"
}
}
}
}
}
}
},
"/items": {
"post": {
"operationId": "create_item",
"summary": "Create an item",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateItem"
}
}
}
},
"responses": {
"201": {
"description": "Item created"
}
}
},
"put": {
"operationId": "update_item",
"summary": "Update an item",
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateItem"
}
}
}
},
"responses": {
"200": {
"description": "Item updated"
}
}
}
},
"/unnamed": {
"get": {
"summary": "Unnamed operation",
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/with-header": {
"get": {
"operationId": "with_header",
"summary": "Operation with header and cookie params",
"parameters": [
{
"name": "X-Request-Id",
"in": "header",
"schema": {
"type": "string"
},
"required": true
},
{
"name": "session",
"in": "cookie",
"schema": {
"type": "string"
},
"required": false
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/with-default": {
"get": {
"operationId": "with_default",
"summary": "Operation with default response",
"responses": {
"200": {
"description": "Success"
},
"default": {
"description": "Error response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/no-body": {
"post": {
"operationId": "no_body",
"summary": "POST without request body",
"responses": {
"204": {
"description": "No content"
}
}
}
},
"/arrays": {
"get": {
"operationId": "get_arrays",
"summary": "Get arrays",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ArrayWithConstraints"
}
}
}
}
}
}
},
"/objects": {
"get": {
"operationId": "get_objects",
"summary": "Get objects",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ObjectWithConstraints"
}
}
}
}
}
}
},
"/typed": {
"get": {
"operationId": "get_typed",
"summary": "Get typed properties",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TypedProperties"
}
}
}
}
}
}
},
"/refs": {
"get": {
"operationId": "get_refs",
"summary": "Get via ref chain",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RefChainA"
}
}
}
}
}
}
},
"/oneof": {
"get": {
"operationId": "get_oneof",
"summary": "Get oneOf schema",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MultiOneOf"
}
}
}
}
}
}
},
"/anyof": {
"get": {
"operationId": "get_anyof",
"summary": "Get anyOf schema",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AnyOfExample"
}
}
}
}
}
}
},
"/allof": {
"get": {
"operationId": "get_allof",
"summary": "Get allOf schema",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MultiAllOf"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"GreetingResponse": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "The greeting message"
},
"via_ref": {
"$ref": "#/components/schemas/SubType"
},
"via_allof": {
"description": "Via allOf.",
"allOf": [
{
"$ref": "#/components/schemas/SubType"
}
]
},
"via_anyof": {
"description": "Via anyOf.",
"anyOf": [
{
"$ref": "#/components/schemas/SubType"
}
]
},
"via_oneof": {
"description": "Via oneOf.",
"oneOf": [
{
"$ref": "#/components/schemas/SubType"
}
]
},
"via_clone": {
"description": "Via clone of SubType using allOf.",
"allOf": [
{
"$ref": "#/components/schemas/SubTypeClone"
}
]
},
"not_a_number": {
"not": {
"type": "number"
}
}
},
"required": [
"message"
]
},
"SubType": {
"type": "object",
"properties": {
"value": {
"type": "string"
}
}
},
"SubTypeClone": {
"description": "...",
"allOf": [
{
"$ref": "#/components/schemas/SubType"
}
]
},
"Tree": {
"type": "object",
"properties": {
"children": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Tree"
}
}
}
},
"CreateItem": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"kind": {
"$ref": "#/components/schemas/ItemKind"
},
"type": {
"$ref": "#/components/schemas/ItemType"
}
},
"required": [
"name"
]
},
"UpdateItem": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"ErrorResponse": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"code": {
"type": "integer"
}
},
"required": [
"message",
"code"
]
},
"ArrayWithConstraints": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"maxItems": 10,
"uniqueItems": false
},
"ObjectWithConstraints": {
"type": "object",
"minProperties": 1,
"maxProperties": 5,
"additionalProperties": {
"type": "string"
}
},
"MultiOneOf": {
"oneOf": [
{
"type": "string"
},
{
"type": "integer"
}
]
},
"MultiAllOf": {
"allOf": [
{
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
},
{
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
}
]
},
"AnyOfExample": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
}
]
},
"TypedProperties": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"enabled": {
"type": "boolean"
},
"ratio": {
"type": "number"
}
}
},
"RefChainA": {
"$ref": "#/components/schemas/RefChainB"
},
"RefChainB": {
"$ref": "#/components/schemas/SubType"
},
"ItemKind": {
"enum": [
"compassionate",
"thoughtful",
"caring",
"considerate"
]
},
"ItemType": {
"oneOf": [
{
"description": "verb; to enter (data, text, etc.) by means of a keyboard",
"type": "string",
"enum": [
"keyboard"
]
},
{
"description": "verb; to enter (data) into a computer or data processing system",
"type": "string",
"enum": [
"input"
]
},
{
"description": "verb; to form letters, words, or symbols on a surface (such as paper or a screen) using an instrument like a pen, pencil, or keyboard to communicate, record information, or create literature",
"type": "string",
"enum": [
"write"
]
}
]
}
}
}
}