Added more components and upload endpoint

This commit is contained in:
2022-01-21 17:06:38 +01:00
parent a23773acd4
commit 65bac399f2

View File

@@ -4,7 +4,7 @@ info:
description: TheAdversary api
version: 1.0.0
servers:
- url: 'https://localhost:8080'
- url: 'http://localhost:8080'
paths:
/api/recent:
get:
@@ -27,7 +27,6 @@ paths:
type: array
items:
$ref: '#/components/schemas/ArticleSummary'
/api/search:
get:
summary: Search all articles
@@ -64,14 +63,19 @@ paths:
type: array
items:
$ref: '#/components/schemas/ArticleSummary'
components:
schemas:
ArticleSummary:
/api/upload:
post:
summary: "Uploads a new article"
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
title:
type: string
description: Title of the article
description: "Name of the article. Must be unique"
summary:
type: string
description: A short overview summary of the article
@@ -79,6 +83,88 @@ components:
type: string
description: Link to a preview image
nullable: true
tags:
type: array
description: Tags the article should have. If the tag does not exist, a new one is created automatically
items:
$ref: '#/components/schemas/Tag'
security:
- cookie: []
responses:
201:
description: The article was created
401:
description: Not authorized
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
409:
description: A article with the same title already exists
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
components:
schemas:
ApiError:
type: object
properties:
message:
type: string
description: Error message
ArticleSummary:
type: object
properties:
id:
type: number
description: The article id
title:
type: string
description: Title of the article
summary:
type: string
description: A short overview summary of the article
author:
$ref: '#/components/schemas/Author'
image:
type: string
description: Link to a preview image
nullable: true
tags:
type: array
items:
$ref: '#/components/schemas/Tag'
link:
type: string
description: Link to the article itself
Author:
type: object
properties:
id:
type: number
description: Id of the author
name:
type: string
description: The author name
information:
type: string
description: Further information about the author
nullable: true
Tag:
type: object
properties:
id:
type: number
description: The tag id
name:
type: string
description: Name of the tag
securitySchemes:
cookie:
type: apiKey
in: cookie
name: session_id