Skip to content
Permalink
Browse files
Added Open API documentation for applications
  • Loading branch information
skondram committed Nov 29, 2021
1 parent f6341cf commit 5905e0c28b49d1e2091fa06c2f0356d5f7029404
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 46 deletions.
@@ -8,7 +8,7 @@
const {Validator, ValidationError} = require('jsonschema');

const userSchema = require('../schemas/user.json').definitions.user;
const appSchema = require('../schemas/application.schema.js');
const appSchema = require('../schemas/application.json').definitions.application;

/**
* Wrapper that returns a Koa middleware validator for a given schema.
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Blog API Docs</title>
<title>Gym API Docs</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
@@ -0,0 +1,81 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"definitions": {
"application": {

"title": "Application",
"description": "Gym membership application",

"type": "object",
"properties": {

"firstName": {
"type": "string",
"maxLength": 64,
"description": "First Name"
},

"lastName": {
"type": "string",
"maxLength": 64,
"description": "Last Name"
},

"email": {
"type": "string",
"maxLength": 64,
"description": "Email of user"
},

"address": {
"type": "string",
"maxLength": 255,
"description": "Address of user"
},

"paymentDetails": {
"type": "string",
"maxLength": 64,
"description": "Payment Details of user"
},

"fitnessGoals": {
"type": "string",
"maxLength": 255,
"description": "User's fitness goals"
},

"medicalHistory": {
"type": "string",
"maxLength": 255,
"description": "Medical history of user"
}
},

"required": [""],
"additionalProperties": false
},

"applicationCreation": {
"$id": "#applicationCreation",
"title": "Application Creation",
"description": "Creation of application",

"type": "object",
"properties": {
"ID": {
"description": "ID of created application",
"type": "Integer"
}
}

},
"getAllApplications": {
"$id": "#getAllApplications",
"title": "Getting all applications",
"description": "JSON data of application returned",
"type": "object",
"allOf": [{ "$ref": "#/definitions/application" }]
}
}
}

This file was deleted.

@@ -10,13 +10,13 @@ info:
name: Apache 2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
servers:
- url: 'https://ecology-fiction-3000.codio-box.uk/api/v1'
- url: 'https://exile-region-3000.codio-box.uk/api/v1'
description: Development server
tags:
- name: Users
description: API endpoints for user management.
- name: Articles
description: Access and perform CRUD operations on blog entries.
- name: Applications
description: Access and perform CRUD operations on application entries.
paths:
/users:
summary: Represents an individual user
@@ -116,4 +116,106 @@ paths:
'401':
description: Only admin users can delete accounts
'404':
description: Not found
description: Not found
/applications:
summary: Represents membership application resource
description: This resource represents membership application resources stored within the database.
get:
tags:
- Applications
description:
Retrieve all membership applications from database.
responses:
'200':
description: All membership applications retrieved
content:
application/json:
schema:
$ref: ./application.json#/definitions/getAllApplications


post:
tags:
- Applications
description:
Create a membership application.
requestBody:
description: New membership application data added.
required: true
content:
application/json:
schema:
$ref: ./application.json#/definitions/application
responses:
'201':
description: Application submitted successfully.
content:
application/json:
schema:
$ref: ./application.json#/definitions/applicationCreation
'500':
description: Internal server error.



/applications/{id}:
parameters:
- in: path
name: id
content:
application/json
required: true
description: id of membership.
get:
tags:
- Applications
description: Retrieves membership application based on ID

responses:
'200':
description: Membership application returned.
content:
application/json:
schema:
$ref: ./application.json#/definitions/application

put:
tags:
- Applications
description: Update membership application by id
responses:
'200':
description: Application updated successfully.
content:
application/json:
schema:
$ref: ./application.json#/definitions/applicationCreation
'403':
description: Only admins have the necessary permissions to update this record.
'404':
description: Not Found.
'500':
description: Internal Server Error.
delete:
tags:
- Applications
description: Remove membership application by id
responses:
'200':
description: Membership application deleted successfully.
content:
application/json:
schema:
$ref: ./application.json#/definitions/applicationCreation

'403':
description: Only admins have the necessary necessary permissions to delete this record.
'404':
description: Not Found.
'500':
description: Internal Server Error.

0 comments on commit 5905e0c

Please sign in to comment.