-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from benAkehurst/add-swagger
WIP - Adding swagger docs
- Loading branch information
Showing
12 changed files
with
300 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module.exports = { | ||
post: { | ||
tags: ["Auth CRUD Operations"], | ||
description: "Creates a new user.", | ||
operationId: "Create new user", | ||
parameters: [], | ||
requestBody: { | ||
content: { | ||
"application/json": { | ||
schema: { | ||
$ref: "#/components/schemas/createUser", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
responses: { | ||
400: { | ||
description: "Please provide all required fields", | ||
description: "The entered passwords do not match!", | ||
description: | ||
"Your password must be at least 6 characters long and contain a lowercase letter, an uppercase letter, a numeric digit and a special character.", | ||
description: "You need to accept the terms of use.", | ||
description: "Email address has invalid format", | ||
description: "Error creating user", | ||
}, | ||
201: { | ||
description: "User created", | ||
}, | ||
500: { | ||
description: "General Error Creating new account", | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const login = require("./login-user"); | ||
const createUser = require("./create-user"); | ||
|
||
module.exports = { | ||
paths: { | ||
"/login": { | ||
...login, | ||
}, | ||
"/create-new-user": { | ||
...createUser, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = { | ||
post: { | ||
tags: ["Auth CRUD Operations"], | ||
description: "Login to app and create session.", | ||
operationId: "login", | ||
parameters: [], | ||
requestBody: { | ||
content: { | ||
"application/json": { | ||
schema: { | ||
$ref: "#/components/schemas/loginInput", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
responses: { | ||
400: { | ||
description: "The provided email is not registered.", | ||
description: "Email and password do not match.", | ||
}, | ||
200: { | ||
description: "Successfully logged in", | ||
}, | ||
500: { | ||
description: "Something went wrong.", | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
openapi: "3.0.3", | ||
info: { | ||
title: "APC Nodejs API", | ||
description: "Services for APC", | ||
version: "1.0.0", | ||
contact: { | ||
name: "Ben Akehurst", | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
module.exports = { | ||
components: { | ||
schemas: { | ||
// User Model | ||
user: { | ||
type: "object", | ||
properties: { | ||
firstName: { | ||
type: "string", | ||
description: "User's first name.", | ||
example: "John", | ||
}, | ||
lastName: { | ||
type: "string", | ||
description: "User's last name.", | ||
example: "Doe", | ||
}, | ||
email: { | ||
type: "string", | ||
description: "User's email address.", | ||
example: "john@doe.com", | ||
}, | ||
password: { | ||
type: "string", | ||
description: | ||
"Password for user account. password must be at least 6 characters long and contain a lowercase letter, an uppercase letter, a numeric digit and a special character.", | ||
example: "Abc123!@", | ||
}, | ||
acceptedTerms: { | ||
type: "boolean", | ||
description: "Confirms the user accepts t's & c's on sign up.", | ||
example: "true", | ||
}, | ||
createdOnDate: { | ||
type: "boolean", | ||
description: | ||
"A human readable format of the date the user was created.", | ||
example: "12/11/2021", | ||
}, | ||
userUID: { | ||
type: "string", | ||
description: "A UUID for the user object.", | ||
example: "8eac14c0-83b4-46f7-a9ef-bef5ded8997f", | ||
}, | ||
userAcquisitionLocation: { | ||
type: "string", | ||
description: | ||
"Defines where the user opened their account, via the sign up form or using goolge credentials.", | ||
example: "Manual Registration Form", | ||
}, | ||
trackedItems: { | ||
type: "array", | ||
description: "Array of object ids of items the user is tracking.", | ||
example: "[]", | ||
}, | ||
isAdmin: { | ||
type: "boolean", | ||
description: "Defines if the user is an admin.", | ||
example: "false", | ||
}, | ||
userActive: { | ||
type: "boolean", | ||
description: "Defines if the user confirmed their email address.", | ||
example: "false", | ||
}, | ||
}, | ||
}, | ||
// Item Model | ||
singleItem: { | ||
type: "object", | ||
properties: { | ||
name: { | ||
type: "string", | ||
description: "Item name.", | ||
example: "Samsung-LC32R500FHRXXU-Curved-FullHD-Monitor", | ||
}, | ||
link: { | ||
type: "string", | ||
description: "Valid Amazon url of item.", | ||
example: | ||
"https://www.amazon.co.uk/Samsung-LC32R500FHRXXU-Curved-FullHD-Monitor/dp/B08WXCZT4Y", | ||
}, | ||
imgUrl: { | ||
type: "string", | ||
description: "Scraped url for main image url.", | ||
example: | ||
"https://m.media-amazon.com/images/I/81kfNKhZp+L._AC_SX300_SY300_.jpg", | ||
}, | ||
currentPrice: { | ||
type: "number", | ||
description: | ||
"Current item price rounded to the nearest whole number.", | ||
example: "179", | ||
}, | ||
targetPrice: { | ||
type: "number", | ||
description: | ||
"A user defined number the user would like to pay for the item.", | ||
example: "175", | ||
}, | ||
asin: { | ||
type: "string", | ||
description: "Amazon SKU.", | ||
example: "B08WXCZT4Y", | ||
}, | ||
rating: { | ||
type: "string", | ||
description: "Current rating.", | ||
example: "4.5 out of 5 stars", | ||
}, | ||
following: { | ||
type: "boolean", | ||
description: | ||
"Tracks if the user is tracking the price and the item price is being updated.", | ||
example: "true", | ||
}, | ||
pastPrices: { | ||
type: "array", | ||
description: | ||
"Holds a record of past prices. This array is updated each time the item price is updated.", | ||
example: "[{time: 1636729931796, pastPrice: 179}]", | ||
}, | ||
}, | ||
}, | ||
loginInput: { | ||
type: "object", | ||
properties: { | ||
email: { | ||
type: "string", | ||
description: "user email", | ||
example: "john@doe.com", | ||
}, | ||
password: { | ||
type: "string", | ||
description: "user password", | ||
example: "Abc123!@", | ||
}, | ||
rememberMe: { | ||
type: "boolean", | ||
description: "Defines if user is to remain logged in", | ||
example: "true", | ||
}, | ||
}, | ||
}, | ||
createUser: { | ||
type: "object", | ||
properties: { | ||
firstName: { | ||
type: "string", | ||
description: "User's first name.", | ||
example: "John", | ||
}, | ||
lastName: { | ||
type: "string", | ||
description: "User's last name.", | ||
example: "Doe", | ||
}, | ||
email: { | ||
type: "string", | ||
description: "User's email address.", | ||
example: "john@doe.com", | ||
}, | ||
password: { | ||
type: "string", | ||
description: | ||
"Password for user account. password must be at least 6 characters long and contain a lowercase letter, an uppercase letter, a numeric digit and a special character.", | ||
example: "Abc123!@", | ||
}, | ||
password2: { | ||
type: "string", | ||
description: "A repeat of the first password", | ||
example: "Abc123!@", | ||
}, | ||
acceptedTerms: { | ||
type: "boolean", | ||
description: "Confirms the user accepts t's & c's on sign up.", | ||
example: "true", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const basicInfo = require("./basicInfo"); | ||
const servers = require("./servers"); | ||
const tags = require("./tags"); | ||
const components = require("./components"); | ||
const auth = require("./auth"); | ||
|
||
module.exports = { | ||
...basicInfo, | ||
...servers, | ||
...tags, | ||
...components, | ||
...auth, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
servers: [{ url: "http://localhost:5000", description: "Dev Server" }], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
tags: [{ name: "Auth CRUD Operations" }, { name: "Scraper CRUD Operations" }], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters