📋JSON Templates
OpenAPI/Swagger Endpoint Spec
OpenAPI 3.0 endpoint specification with parameters and responses.
Explanation
OpenAPI spec describes your REST API in a standard, machine-readable format.
Examples
GET Endpoint
Output
{
"/users/{id}": {
"get": {
"summary": "Get user by ID",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "User found",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
}
}
}
}
}
},
"404": {
"description": "User not found"
}
}
}
}
}Code Examples
OpenAPI YAML
openapi: 3.0.0
info:
title: My API
version: 1.0.0
paths:
/users/{id}:
get:
summary: Get user by ID
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
'200':
description: User found
content:
application/json:
schema:
$ref: '#/components/schemas/User'Try it Now
💡 Tips
- Use YAML for better readability
- Define reusable schemas in components
- Document all status codes
- Include examples for complex types
- Use $ref for schema reuse
⚠️ Common Pitfalls
- Keep spec in sync with actual API
- Don't forget to document authentication
- Complex schemas can be hard to maintain