{ "openapi": "3.0.0", "info": { "title": "API with Security Schemes", "description": "An API that demonstrates various security schemes", "version": "1.0.0" }, "servers": [ { "url": "https://api.example.com/v1", "description": "Production server" } ], "security": [ { "bearerAuth": [] } ], "components": { "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer", "description": "Bearer token authentication" }, "basicAuth": { "type": "http", "scheme": "basic", "description": "Basic authentication" }, "apiKey": { "type": "apiKey", "in": "header", "name": "X-API-Key", "description": "API Key authentication" }, "oauth2": { "type": "oauth2", "flows": { "authorizationCode": { "authorizationUrl": "https://auth.example.com/oauth/authorize", "tokenUrl": "https://auth.example.com/oauth/token", "scopes": { "read": "Read access", "write": "Write access", "admin": "Admin access" } } }, "description": "OAuth 2.0 authentication" } } }, "paths": { "/users": { "get": { "summary": "Get users", "description": "Retrieve a list of users", "security": [ { "bearerAuth": [] } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "email": { "type": "string" } } } } } } } } }, "post": { "summary": "Create user", "description": "Create a new user", "security": [ { "bearerAuth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" }, "email": { "type": "string" } }, "required": ["name", "email"] } } } }, "responses": { "201": { "description": "User created", "content": { "application/json": { "schema": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "email": { "type": "string" } } } } } } } } }, "/admin/users": { "get": { "summary": "Admin get users", "description": "Retrieve all users (admin only)", "security": [ { "oauth2": ["admin"] } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "email": { "type": "string" } } } } } } } } } }, "/public/data": { "get": { "summary": "Get public data", "description": "Retrieve public data without authentication", "security": [], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string" }, "timestamp": { "type": "string" } } } } } } } } } } }