This commit is contained in:
2025-07-27 01:10:54 +03:00
parent 1dc7c4fd87
commit deab475eab
6 changed files with 138 additions and 0 deletions

133
api/todo/api.yaml Normal file
View File

@ -0,0 +1,133 @@
openapi: 3.0.0
info:
title: Todo CRUD API
version: 1.0.0
servers:
- url: https://api.example.com/v1
paths:
/todos:
get:
summary: Get all todos
responses:
'200':
description: A list of todos
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Todo'
post:
summary: Create a new todo
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/TodoCreate'
responses:
'201':
description: Todo created
content:
application/json:
schema:
$ref: '#/components/schemas/Todo'
/todos/{todoId}:
get:
summary: Get a todo by ID
parameters:
- name: todoId
in: path
required: true
schema:
type: string
responses:
'200':
description: Todo details
content:
application/json:
schema:
$ref: '#/components/schemas/Todo'
'404':
description: Todo not found
put:
summary: Update a todo by ID
parameters:
- name: todoId
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/TodoUpdate'
responses:
'200':
description: Todo updated
content:
application/json:
schema:
$ref: '#/components/schemas/Todo'
'404':
description: Todo not found
delete:
summary: Delete a todo by ID
parameters:
- name: todoId
in: path
required: true
schema:
type: string
responses:
'204':
description: Todo deleted successfully
'404':
description: Todo not found
components:
schemas:
Todo:
type: object
properties:
id:
type: string
example: "1"
title:
type: string
example: "Buy groceries"
description:
type: string
example: "Milk, Bread, Eggs"
completed:
type: boolean
example: false
required:
- id
- title
- completed
TodoCreate:
type: object
properties:
title:
type: string
example: "Buy groceries"
description:
type: string
example: "Milk, Bread, Eggs"
required:
- title
TodoUpdate:
type: object
properties:
title:
type: string
example: "Buy more groceries"
description:
type: string
example: "Milk, Bread, Eggs, Cheese"
completed:
type: boolean
example: true