Skip to content

Commit

Permalink
fix: user creation POST route returns user data, updated openapi spec
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Oct 8, 2020
1 parent 91b79f1 commit bba2a46
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 43 deletions.
101 changes: 62 additions & 39 deletions openapi.yaml
Expand Up @@ -160,6 +160,21 @@ components:
userslug:
type: string
example: dragon-fruit
email:
type: string
example: dragonfruit@example.org
email:confirmed:
type: number
example: 1
joindate:
type: number
example: 1585337827953
lastonline:
type: number
example: 1585337827953
picture:
type: string
example: https://images.unsplash.com/photo-1560070094-e1f2ddec4337?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=256&h=256&q=80
fullname:
type: string
example: Mr. Dragon Fruit Jr.
Expand All @@ -184,64 +199,72 @@ components:
example: |
This is an example signature
It can span multiple lines.
groupTitle:
type: string
example: "[\"administrators\",\"Staff\"]"
uploadedpicture:
type: string
example: /assets/profile/1-profileimg.png
description: In almost all cases, defer to "picture" instead. Use this if you need to specifically reference the picture uploaded to the forum.
cover:url:
type: string
example: /assets/profile/1-cover.png
cover:position:
type: string
example: 50.0301% 19.2464%
picture:
type: string
example: https://images.unsplash.com/photo-1560070094-e1f2ddec4337?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=256&h=256&q=80
status:
type: string
example: online
postcount:
type: number
example: 1000
topiccount:
type: number
example: 50
followercount:
type: number
example: 2
followingcount:
type: number
example: 5
profileviews:
type: number
example: 1000
reputation:
type: number
example: 100
email:
type: string
example: dragonfruit@example.org
email:confirmed:
postcount:
type: number
example: 1
lastonline:
example: 1000
topiccount:
type: number
example: 1585337827953
example: 50
lastposttime:
type: number
example: 1585337827953
flags:
type: number
example: 0
banned:
type: number
example: 0
banned:expire:
type: number
example: 1585337827953
joindate:
status:
type: string
example: online
flags:
type: number
example: 0
followercount:
type: number
example: 2
followingcount:
type: number
example: 1585337827953
example: 5
cover:url:
type: string
example: /assets/profile/1-cover.png
cover:position:
type: string
example: 50.0301% 19.2464%
groupTitle:
type: string
example: "[\"administrators\",\"Staff\"]"
groupTitleArray:
type: array
example:
- administrators
- Staff
icon:text:
type: string
example: D
icon:bgColor:
type: string
example: "#9c27b0"
joindateISO:
type: string
example: 2020-03-27T20:30:36.590Z
lastonlineISO:
type: string
example: 2020-03-27T20:30:36.590Z
banned_until:
type: number
example: 0
banned_until_readable:
type: string
example: Not Banned
2 changes: 1 addition & 1 deletion src/middleware/index.js
Expand Up @@ -243,7 +243,7 @@ middleware.checkRequired = function (fields, req, res, next) {
const missing = fields.filter(field => !req.body.hasOwnProperty(field));

if (!missing.length) {
next();
return next();
}

controllers.helpers.formatApiResponse(400, res, new Error('Required parameters were missing from this API call: ' + missing.join(', ')));
Expand Down
4 changes: 1 addition & 3 deletions src/routes/write/users.js
Expand Up @@ -17,9 +17,7 @@ module.exports = function () {

app.post('/', middleware.checkRequired.bind(null, ['username']), middleware.authenticate, middleware.isAdmin, async (req, res) => {
const uid = await users.create(req.body);
helpers.formatApiResponse(200, res, {
uid: uid,
});
helpers.formatApiResponse(200, res, await users.getUserData(uid));
});

// app.route('/:uid')
Expand Down

0 comments on commit bba2a46

Please sign in to comment.