Update code to create posts

This commit is contained in:
2025-02-21 21:49:00 +11:00
parent 076f63bf8a
commit c238ed4cc4
5 changed files with 107 additions and 503 deletions
+69 -46
View File
@@ -49,10 +49,10 @@ paths:
schema:
$ref: '#/components/schemas/Page'
/api/newsletters:
/api/posts:
get:
summary: List all newsletters
description: Retrieve a paginated list of all newsletters
summary: List all posts
description: Retrieve a paginated list of all posts
parameters:
- in: query
name: page
@@ -70,24 +70,24 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/NewsletterList'
$ref: '#/components/schemas/PostList'
post:
summary: Create a new newsletter
description: Create a new newsletter with the provided data
summary: Create a new post
description: Create a new post with the provided data
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/NewsletterCreate'
$ref: '#/components/schemas/PostCreate'
responses:
'201':
description: Newsletter created successfully
description: Post created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Newsletter'
$ref: '#/components/schemas/Post'
/api/collections:
get:
@@ -151,8 +151,8 @@ paths:
/api/collections/{collection_id}/upload_images:
post:
summary: Upload images to collection
description: Upload one or multiple images to a collection
summary: Upload images to a collection
description: Upload one or more images to a collection with optional descriptions
parameters:
- in: path
name: collection_id
@@ -160,7 +160,7 @@ paths:
schema:
type: string
format: uuid
description: The ID of the collection
description: The ID of the collection to upload images to
requestBody:
required: true
content:
@@ -173,13 +173,33 @@ paths:
items:
type: string
format: binary
description: List of image files to upload. Only image/* content types are allowed.
descriptions:
type: array
items:
type: string
description: Optional list of descriptions for the uploaded images. Each description corresponds to the image at the same index.
required:
- file
responses:
'201':
description: Images uploaded successfully
content:
application/json:
schema:
$ref: '#/components/schemas/ImageUploadResponse'
type: object
properties:
status:
type: string
enum: [success]
example: success
message:
type: string
example: "Successfully uploaded 2 images"
data:
type: array
items:
$ref: '#/components/schemas/Image'
/api/images/{image_id}:
delete:
@@ -254,38 +274,43 @@ components:
items:
$ref: '#/components/schemas/Page'
Newsletter:
Post:
type: object
properties:
id:
type: integer
title:
type: string
type:
type: string
enum: [technology, world_news]
content:
type: string
tag_details:
type: array
items:
$ref: '#/components/schemas/Tag'
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
NewsletterCreate:
PostCreate:
type: object
required:
- title
- type
- content
properties:
title:
type: string
type:
type: string
enum: [technology, world_news]
content:
type: string
tags:
type: array
items:
type: string
description: List of tag slugs to associate with the post
NewsletterList:
PostList:
type: object
properties:
count:
@@ -299,7 +324,19 @@ components:
results:
type: array
items:
$ref: '#/components/schemas/Newsletter'
$ref: '#/components/schemas/Post'
Tag:
type: object
properties:
id:
type: integer
name:
type: string
slug:
type: string
description:
type: string
Collection:
type: object
@@ -360,30 +397,25 @@ components:
id:
type: string
format: uuid
collection:
type: string
format: uuid
title:
type: string
description:
type: string
content_type:
type: string
size:
type: integer
url:
type: string
created_at:
type: string
format: date-time
ImageUploadResponse:
type: object
properties:
status:
updated_at:
type: string
enum: [success]
message:
format: date-time
url:
type: string
data:
type: array
items:
$ref: '#/components/schemas/Image'
SuccessResponse:
type: object
@@ -393,12 +425,3 @@ components:
enum: [success]
message:
type: string
ErrorResponse:
type: object
properties:
status:
type: string
enum: [error]
message:
type: string