style(openapi): break write API routes into individual files

This commit is contained in:
psychobunny
2020-10-09 11:07:25 -04:00
committed by Andrew Rodrigues
parent ffac3c7902
commit dbb4cfe9d6
144 changed files with 1177 additions and 1160 deletions

View File

@@ -0,0 +1,25 @@
put:
tags:
- admin
summary: update configuration setting
description: This operation updates a configuration setting in the backend. The calling user must have the `admin:settings` privilege (or be a superadmin) in order for this call to proceed.
parameters:
- in: path
name: setting
schema:
type: string
required: true
description: backend id of the setting to update
responses:
'200':
description: Admin setting updated
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,58 @@
post:
tags:
- categories
summary: create a category
description: This operation creates a new category
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
name:
type: string
description:
type: string
parentCid:
type: number
cloneFromCid:
type: number
icon:
type: string
description: A ForkAwesome icon without the `fa-` prefix
bgColor:
type: string
color:
type: string
link:
type: string
class:
type: string
backgroundImage:
type: string
required:
- name
example:
name: My New Category
description: Lorem ipsum, dolor sit amet
parentCid: 0
cloneFromCid: 0
icon: bullhorn
bgColor: '#ffffff'
color: '#000000'
link: 'https://example.org'
class: 'col-md-3 col-xs-6'
backgroundImage: '/assets/relative/path/to/image'
responses:
'200':
description: category successfully created
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
$ref: ../components/schemas/CategoryObj.yaml#/CategoryObj

View File

@@ -0,0 +1,32 @@
delete:
tags:
- files
summary: delete uploaded file
description: This operation deletes a file uploaded to NodeBB
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
path:
type: string
description: Path to the file (relative to the configured `upload_path`)
required:
- path
example:
path: files/uploaded_file.jpg
responses:
'200':
description: File deleted
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,72 @@
post:
tags:
- groups
summary: create a new group
description: This operation creates a new group
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
name:
type: string
timestamp:
type: number
disableJoinRequests:
type: number
enum: [0, 1]
disableLeave:
type: number
enum: [0, 1]
hidden:
type: number
enum: [0, 1]
ownerUid:
type: number
private:
type: number
enum: [0, 1]
description:
type: string
userTitleEnabled:
type: number
enum: [0, 1]
createtime:
type: number
required:
- name
example:
name: 'My Test Group'
hidden: 1
responses:
'200':
description: group successfully created
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
$ref: ../components/schemas/GroupObject.yaml#/GroupDataObject
delete:
tags:
- groups
summary: Delete an existing group
description: This operation deletes an existing group, all members within this group will cease to be members after the group is deleted.
responses:
'200':
description: group successfully deleted
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,18 @@
put:
tags:
- groups
summary: join a group
description: This operation joins an existing group, or causes another user to join a group. If the group is private and you are not an administrator, this method will cause that user to request membership, instead. For user _invitations_, you'll want to call `PUT /groups/{slug}/invites/{uid}`.
responses:
'200':
description: group successfully joined, or membership requested
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,53 @@
put:
tags:
- posts
summary: edit a post
description: This operation edits a post
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
content:
type: string
description: New post content
title:
type: string
description: Topic title, only accepted for main posts
required:
- content
example:
content: 'New post content'
title: 'New title'
responses:
'200':
description: Post successfully edited
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../components/schemas/Status.yaml#/Status
response:
$ref: ../../components/schemas/PostsObject.yaml#/PostsObject
delete:
tags:
- posts
summary: purge a post
description: This operation purges a post.
responses:
'200':
description: Post successfully purged
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,36 @@
put:
tags:
- posts
summary: bookmark a post
description: This operation bookmarks a post.
responses:
'200':
description: Post successfully bookmarked
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}
delete:
tags:
- posts
summary: unbookmark a post
description: This operation unbookmarks a post.
responses:
'200':
description: Post successfully unbookmarked
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,36 @@
put:
tags:
- posts
summary: restore a post
description: This operation restores a post.
responses:
'200':
description: Topic successfully restored
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}
delete:
tags:
- posts
summary: deletes a post
description: This operation soft deletes a post.
responses:
'200':
description: Post successfully deleted
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,48 @@
put:
tags:
- posts
summary: vote on a post
description: This operation casts a vote on a post.
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
delta:
type: number
description: Positive integer for upvote, negative integer for downvote (0 to unvote.)
example:
delta: 1
responses:
'200':
description: Post successfully upvoted
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}
delete:
tags:
- posts
summary: unvote a post
description: This operation removes a pre-cast vote on a post.
responses:
'200':
description: Post successfully unvoted
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,42 @@
post:
tags:
- topics
summary: create a new topic
description: This operation creates a new topic with a post. Topic creation without a post is not allowed via the Write API as it is an internal-only method.
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
cid:
type: number
title:
type: string
content:
type: string
tags:
type: array
items:
type: string
required:
- cid
- title
- content
example:
cid: 1
title: Test topic
content: This is the test topic's content
responses:
'200':
description: topic successfully created
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
$ref: ../components/schemas/TopicObject.yaml#/TopicObject

View File

@@ -0,0 +1,52 @@
post:
tags:
- topics
summary: peply to a topic
description: This operation creates a new reply to an existing topic.
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
content:
type: string
timestamp:
type: number
toPid:
type: number
required:
- content
example:
content: This is a test reply
responses:
'200':
description: post successfully created
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../components/schemas/Status.yaml#/Status
response:
$ref: ../../components/schemas/PostsObject.yaml#/PostsObject
delete:
tags:
- topics
summary: delete a topic
description: This operation purges a topic and all of its posts (careful, there is no confirmation!)
responses:
'200':
description: Topic successfully purged
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,36 @@
put:
tags:
- topics
summary: follow a topic
description: This operation follows (or watches) a topic.
responses:
'200':
description: Topic successfully followed
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}
delete:
tags:
- topics
summary: unfollow a topic
description: This operation unfollows (or unwatches) a topic.
responses:
'200':
description: Topic successfully unwatched
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,36 @@
put:
tags:
- topics
summary: ignore a topic
description: This operation ignores (or watches) a topic.
responses:
'200':
description: Topic successfully ignored
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}
delete:
tags:
- topics
summary: unignore a topic
description: This operation unignores (or unfollows/unwatches) a topic. It is functionally identical to `DEL /topics/{tid}/follow`.
responses:
'200':
description: Topic successfully unignored/unwatched
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,36 @@
put:
tags:
- topics
summary: lock a topic
description: This operation locks an existing topic.
responses:
'200':
description: Topic successfully locked
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}
delete:
tags:
- topics
summary: unlock a topic
description: This operation unlocks a topic.
responses:
'200':
description: Topic successfully unlocked
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,36 @@
put:
tags:
- topics
summary: pin a topic
description: This operation pins an existing topic.
responses:
'200':
description: Topic successfully pinned
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}
delete:
tags:
- topics
summary: unpin a topic
description: This operation unpins a topic.
responses:
'200':
description: Topic successfully unpinned
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,36 @@
delete:
tags:
- topics
summary: delete a topic
description: This operation deletes an existing topic.
responses:
'200':
description: Topic successfully deleted
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}
put:
tags:
- topics
summary: restore a topic
description: This operation restores a topic.
responses:
'200':
description: Topic successfully restored
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,52 @@
put:
tags:
- topics
summary: adds tags to a topic
description: This operation adds tags to a topic
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
tags:
type: array
description: 'An array of tags'
items:
type: string
example:
tags:
- test
- foobar
responses:
'200':
description: Topic tags successfully added
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}
delete:
tags:
- topics
summary: Removes all tags from a topic
description: This operation removed all tags associated with a topic.
responses:
'200':
description: Topic tags successfully removed.
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../../components/schemas/Status.yaml#/Status
response:
type: object
properties: {}

View File

@@ -0,0 +1,330 @@
post:
tags:
- users
summary: create a user
description: This operation creates a new user account
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
username:
type: string
description: 'If the username is taken, a number will be appended'
password:
type: string
email:
type: string
required:
- username
example:
username: Dragon Fruit
password: s3cre7password
email: dragonfruit@example.org
responses:
'200':
description: user successfully created
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
$ref: ../components/schemas/UserObj.yaml#/UserObj
'400':
$ref: ../components/responses/400.yaml#/400
'401':
$ref: ../components/responses/401.yaml#/401
'403':
$ref: ../components/responses/403.yaml#/403
'426':
$ref: ../components/responses/426.yaml#/426
'500':
$ref: ../components/responses/500.yaml#/500
delete:
tags:
- users
summary: delete one or more users
description: This operation deletes one or many user accounts, including their contributions (posts, topics, etc.)
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
uids:
type: array
description: A collection of uids
items:
type: number
example:
uids:
- 1
- 2
- 3
responses:
'200':
description: user account(s) deleted
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
type: object
'/users/{uid}':
delete:
tags:
- users
summary: delete a single user account
parameters:
- in: path
name: uid
schema:
type: integer
required: true
description: uid of the user to delete
responses:
'200':
description: user account deleted
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
type: object
put:
tags:
- users
summary: update a user account
parameters:
- in: path
name: uid
schema:
type: integer
required: true
description: uid of the user to update
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas/UserRequest.yaml#/UserRequest
responses:
'200':
description: user profile updated
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
$ref: ../components/schemas/UserObj.yaml#/UserObj
'401':
$ref: ../components/responses/401.yaml#/401
'403':
$ref: ../components/responses/403.yaml#/403
'426':
$ref: ../components/responses/426.yaml#/426
'500':
$ref: ../components/responses/500.yaml#/500
'/users/{uid}/password':
put:
tags:
- users
summary: change a user's password
parameters:
- in: path
name: uid
schema:
type: integer
required: true
description: uid of the user to update
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
currentPassword:
type: string
description: test
example: oldp455word
newPassword:
type: string
example: s3cre7password
required:
- newPassword
responses:
'200':
description: user profile updated
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
type: object
'/users/{uid}/follow':
post:
tags:
- users
summary: follow a user
parameters:
- in: path
name: uid
schema:
type: integer
required: true
description: uid of the user to follow
responses:
'200':
description: successfully followed user
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
type: object
delete:
tags:
- users
summary: unfollows a user
parameters:
- in: path
name: uid
schema:
type: integer
required: true
description: uid of the user to unfollow
responses:
'200':
description: successfully unfollowed user
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
type: object
'/users/{uid}/ban':
put:
tags:
- users
summary: ban a user
parameters:
- in: path
name: uid
schema:
type: integer
required: true
description: uid of the user to ban
requestBody:
content:
application/json:
schema:
type: object
properties:
until:
type: number
description: UNIX timestamp of the ban expiry
example: 1585775608076
reason:
type: string
example: the reason for the ban
responses:
'200':
description: successfully banned user
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
type: object
delete:
tags:
- users
summary: unbans a user
parameters:
- in: path
name: uid
schema:
type: integer
required: true
description: uid of the user to unban
responses:
'200':
description: successfully unbanned user
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
type: object
'/users/{uid}/tokens':
post:
tags:
- users
summary: generate a user token
description: This route can only be used to generate tokens for the same user. In other words, you cannot use this route to generate a token for a different user than the one you are authenticated as.
responses:
'200':
description: successfully generated a user token
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
type: object
delete:
tags:
- users
summary: delete user token
parameters:
- in: path
name: token
schema:
type: string
required: true
description: a valid API token
responses:
'200':
description: successfully deleted user token
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../components/schemas/Status.yaml#/Status
response:
type: object