278 lines
6.4 KiB
JSON
278 lines
6.4 KiB
JSON
|
{
|
||
|
"openapi": "3.0.0",
|
||
|
"info": {
|
||
|
"title": "Blog API Documentation",
|
||
|
"version": "1.0.0",
|
||
|
"description": "API documentation for the Blog CRUD application"
|
||
|
},
|
||
|
"tags": [
|
||
|
{
|
||
|
"name": "Blog CRUD",
|
||
|
"description": "Operations related to managing blogs"
|
||
|
},
|
||
|
{
|
||
|
"name": "Category CRUD",
|
||
|
"description": "Operations related to managing categories"
|
||
|
}
|
||
|
],
|
||
|
|
||
|
"servers": [
|
||
|
{
|
||
|
"url": "http://localhost:4000"
|
||
|
}
|
||
|
],
|
||
|
"paths": {
|
||
|
"/blogs": {
|
||
|
"get": {
|
||
|
"tags": ["Blog CRUD"],
|
||
|
"summary": "Retrieve all blogs",
|
||
|
"responses": {
|
||
|
"200": {
|
||
|
"description": "A list of blogs",
|
||
|
"content": {
|
||
|
"application/json": {
|
||
|
"schema": {
|
||
|
"type": "array",
|
||
|
"items": {
|
||
|
"$ref": "#/components/schemas/Blog"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"post": {
|
||
|
"tags": ["Blog CRUD"],
|
||
|
"summary": "Create a new blog",
|
||
|
"requestBody": {
|
||
|
"required": true,
|
||
|
"content": {
|
||
|
"application/json": {
|
||
|
"schema": {
|
||
|
"$ref": "#/components/schemas/Blog"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"responses": {
|
||
|
"201": {
|
||
|
"description": "Blog created successfully"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/blogs/{slug}": {
|
||
|
"get": {
|
||
|
"summary": "Retrieve a blog by slug",
|
||
|
"parameters": [
|
||
|
{
|
||
|
"in": "path",
|
||
|
"name": "slug",
|
||
|
"required": true,
|
||
|
"schema": {
|
||
|
"type": "string"
|
||
|
},
|
||
|
"description": "The slug of the blog"
|
||
|
}
|
||
|
],
|
||
|
"responses": {
|
||
|
"200": {
|
||
|
"description": "A single blog",
|
||
|
"content": {
|
||
|
"application/json": {
|
||
|
"schema": {
|
||
|
"$ref": "#/components/schemas/Blog"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"404": {
|
||
|
"description": "Blog not found"
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"put": {
|
||
|
"summary": "Update a blog by slug",
|
||
|
"parameters": [
|
||
|
{
|
||
|
"in": "path",
|
||
|
"name": "slug",
|
||
|
"required": true,
|
||
|
"schema": {
|
||
|
"type": "string"
|
||
|
},
|
||
|
"description": "The slug of the blog to update"
|
||
|
}
|
||
|
],
|
||
|
"requestBody": {
|
||
|
"required": true,
|
||
|
"content": {
|
||
|
"application/json": {
|
||
|
"schema": {
|
||
|
"$ref": "#/components/schemas/Blog"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"responses": {
|
||
|
"200": {
|
||
|
"description": "Blog updated successfully"
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"delete": {
|
||
|
"summary": "Delete a blog by slug",
|
||
|
"parameters": [
|
||
|
{
|
||
|
"in": "path",
|
||
|
"name": "slug",
|
||
|
"required": true,
|
||
|
"schema": {
|
||
|
"type": "string"
|
||
|
},
|
||
|
"description": "The slug of the blog to delete"
|
||
|
}
|
||
|
],
|
||
|
"responses": {
|
||
|
"204": {
|
||
|
"description": "Blog deleted successfully"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/categories": {
|
||
|
"get": {
|
||
|
"summary": "Retrieve all categories",
|
||
|
"responses": {
|
||
|
"200": {
|
||
|
"description": "A list of categories",
|
||
|
"content": {
|
||
|
"application/json": {
|
||
|
"schema": {
|
||
|
"type": "array",
|
||
|
"items": {
|
||
|
"$ref": "#/components/schemas/Category"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"post": {
|
||
|
"summary": "Create a new category",
|
||
|
"requestBody": {
|
||
|
"required": true,
|
||
|
"content": {
|
||
|
"application/json": {
|
||
|
"schema": {
|
||
|
"$ref": "#/components/schemas/Category"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"responses": {
|
||
|
"201": {
|
||
|
"description": "Category created successfully"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"/categories/{id}": {
|
||
|
"put": {
|
||
|
"summary": "Update a category",
|
||
|
"parameters": [
|
||
|
{
|
||
|
"in": "path",
|
||
|
"name": "id",
|
||
|
"required": true,
|
||
|
"schema": {
|
||
|
"type": "integer"
|
||
|
},
|
||
|
"description": "The ID of the category to update"
|
||
|
}
|
||
|
],
|
||
|
"requestBody": {
|
||
|
"required": true,
|
||
|
"content": {
|
||
|
"application/json": {
|
||
|
"schema": {
|
||
|
"$ref": "#/components/schemas/Category"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"responses": {
|
||
|
"200": {
|
||
|
"description": "Category updated successfully"
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"delete": {
|
||
|
"summary": "Delete a category",
|
||
|
"parameters": [
|
||
|
{
|
||
|
"in": "path",
|
||
|
"name": "id",
|
||
|
"required": true,
|
||
|
"schema": {
|
||
|
"type": "integer"
|
||
|
},
|
||
|
"description": "The ID of the category to delete"
|
||
|
}
|
||
|
],
|
||
|
"responses": {
|
||
|
"204": {
|
||
|
"description": "Category deleted successfully"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"components": {
|
||
|
"schemas": {
|
||
|
"Blog": {
|
||
|
"type": "object",
|
||
|
"required": ["slug", "title", "body"],
|
||
|
"properties": {
|
||
|
"slug": {
|
||
|
"type": "string",
|
||
|
"description": "Unique identifier for the blog"
|
||
|
},
|
||
|
"title": {
|
||
|
"type": "string",
|
||
|
"description": "The title of the blog"
|
||
|
},
|
||
|
"body": {
|
||
|
"type": "string",
|
||
|
"description": "The content of the blog"
|
||
|
},
|
||
|
"categoryIDs": {
|
||
|
"type": "array",
|
||
|
"items": {
|
||
|
"type": "integer"
|
||
|
}
|
||
|
},
|
||
|
"tagIDs": {
|
||
|
"type": "array",
|
||
|
"items": {
|
||
|
"type": "integer"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"Category": {
|
||
|
"type": "object",
|
||
|
"required": ["name"],
|
||
|
"properties": {
|
||
|
"name": {
|
||
|
"type": "string",
|
||
|
"description": "The name of the category"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|