Spring MVC / HTTP
OpenAPI 3.1.1
Machine-readable HTTP contract; not runtime evidence. Boot 4.0.10 companion project; source-reviewed, not executed.
Formal Syntax & Structure
java syntaxjava
"openapi": "3.1.1"Working Example
Example Snippetjava
{ "openapi": "3.1.1", "info": { "title": "Inventory teaching API", "version": "1.0.0" }, "servers": [ { "url": "http://127.0.0.1:18081" } ], "paths": { "/api/v1/items": { "get": { "parameters": [ { "name": "page", "in": "query", "schema": { "type": "integer", "minimum": 0, "maximum": 10000, "default": 0 } }, { "name": "size", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 20 } }, { "name": "sort", "in": "query", "schema": { "type": "string", "enum": [ "sku", "name" ], "default": "sku" } } ], "responses": { "200": { "description": "Page", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Page" } } } }, "400": { "description": "Invalid query", "content": { "application/problem+json": { "schema": { "$ref": "#/components/schemas/Problem" } } } }, "406": { "description": "Not acceptable" } } }, "post": { "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Item" } } } }, "responses": { "201": { "description": "Created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Item" } } }, "headers": { "Location": { "schema": { "type": "string" } } } }, "400": { "description": "Invalid body", "content": { "application/problem+json": { "schema": { "$ref": "#/components/schemas/Problem" } } } }, "409": { "description": "Duplicate SKU", "content": { "application/problem+json": { "schema": { "$ref": "#/components/schemas/Problem" } } } }, "415": { "description": "Unsupported media type" }, "406": { "description": "Not acceptable" } } } }, "/api/v1/items/{sku}": { "get": { "parameters": [ { "name": "sku", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Item" } } } }, "404": { "description": "Missing", "content": { "application/problem+json": { "schema": { "$ref": "#/components/schemas/Problem" } } } }, "406": { "description": "Not acceptable" } } } } }, "components": { "schemas": { "Item": { "type": "object", "required": [ "sku", "name", "quantity" ], "properties": { "sku": { "type": "string", "pattern": "^[A-Z0-9]{1,12}$" }, "name": { "type": "string", "minLength": 1, "maxLength": 80 }, "quantity": { "type": "integer", "minimum": 0, "maximum": 10000 } } }, "Page": { "type": "object", "required": [ "items", "page", "size", "total" ], "properties": { "items": { "type": "array", "items": { "$ref": "#/components/schemas/Item" } }, "page": { "type": "integer" }, "size": { "type": "integer" }, "total": { "type": "integer" } } }, "Problem": { "type": "object", "properties": { "type": { "type": "string" }, "title": { "type": "string" }, "status": { "type": "integer" }, "detail": { "type": "string" }, "instance": { "type": "string" } } } } }}