2021-09-28 23:57:59 +07:00
|
|
|
openapi: "3.0.0"
|
|
|
|
info:
|
|
|
|
version: 0.1.0
|
|
|
|
title: Swagger Hackathon
|
|
|
|
description: A hackathon, hosted in JIS API specification created by Hamza Ali.
|
|
|
|
contact:
|
|
|
|
name: Hamza Ali
|
|
|
|
email: me@hamzantal.pw
|
|
|
|
license:
|
|
|
|
name: MIT License
|
|
|
|
url: "https://hamza.mit-license.org/"
|
|
|
|
|
|
|
|
paths:
|
|
|
|
/auth/code:
|
|
|
|
get:
|
2021-09-30 10:32:18 +07:00
|
|
|
description: Generate oauth exchange url.
|
2021-09-28 23:57:59 +07:00
|
|
|
tags: ["Auth"]
|
|
|
|
operationId: gen oauth
|
|
|
|
parameters:
|
|
|
|
- name: callback
|
|
|
|
in: query
|
|
|
|
required: true
|
|
|
|
schema:
|
|
|
|
type: string
|
|
|
|
format: uri
|
|
|
|
responses:
|
|
|
|
'200':
|
2021-09-30 10:32:18 +07:00
|
|
|
description: OAuth Consent Page URI.
|
2021-09-28 23:57:59 +07:00
|
|
|
content:
|
|
|
|
application/json:
|
|
|
|
schema:
|
|
|
|
$ref: "#/components/schemas/ConsentPage"
|
|
|
|
default:
|
|
|
|
$ref: "#/components/responses/DefaultResponse"
|
|
|
|
|
|
|
|
/auth/authorize:
|
|
|
|
get:
|
2021-09-30 10:32:18 +07:00
|
|
|
description: Authorization response callback location.
|
2021-09-28 23:57:59 +07:00
|
|
|
tags: ["Auth"]
|
|
|
|
operationId: authorize callback
|
|
|
|
parameters:
|
|
|
|
- name: state
|
|
|
|
in: query
|
|
|
|
required: true
|
|
|
|
schema:
|
|
|
|
type: string
|
|
|
|
- name: code
|
|
|
|
in: query
|
|
|
|
required: true
|
|
|
|
schema:
|
|
|
|
type: string
|
|
|
|
responses:
|
|
|
|
'302':
|
2021-09-30 10:32:18 +07:00
|
|
|
description: Redirect to webpage.
|
2021-09-28 23:57:59 +07:00
|
|
|
headers:
|
|
|
|
Location:
|
|
|
|
schema:
|
|
|
|
type: string
|
|
|
|
format: uri
|
|
|
|
default:
|
|
|
|
$ref: "#/components/responses/DefaultResponse"
|
|
|
|
|
|
|
|
/auth/token:
|
|
|
|
delete:
|
|
|
|
tags: ["Auth"]
|
|
|
|
operationId: delete token
|
2021-12-19 15:30:21 +07:00
|
|
|
x-go-middlewares: ["token"]
|
2021-09-28 23:57:59 +07:00
|
|
|
parameters:
|
2021-12-19 15:30:21 +07:00
|
|
|
- $ref: "#/components/parameters/Token"
|
2021-09-28 23:57:59 +07:00
|
|
|
- name: all
|
|
|
|
in: query
|
|
|
|
required: true
|
|
|
|
schema:
|
2021-12-19 15:30:21 +07:00
|
|
|
type: boolean
|
2021-09-28 23:57:59 +07:00
|
|
|
responses:
|
|
|
|
'204':
|
2021-09-30 10:32:18 +07:00
|
|
|
description: User successfully logged out.
|
|
|
|
default:
|
|
|
|
$ref: "#/components/responses/DefaultResponse"
|
|
|
|
|
|
|
|
/users/me:
|
|
|
|
get:
|
|
|
|
description: Get self user information.
|
|
|
|
tags: ["Users"]
|
|
|
|
operationId: get me
|
2021-12-19 15:30:21 +07:00
|
|
|
x-go-middlewares: ["token"]
|
2021-09-30 10:32:18 +07:00
|
|
|
parameters:
|
2021-12-19 15:30:21 +07:00
|
|
|
- $ref: "#/components/parameters/Token"
|
2021-09-30 10:32:18 +07:00
|
|
|
responses:
|
|
|
|
'200':
|
|
|
|
description: User information.
|
|
|
|
content:
|
|
|
|
application/json:
|
|
|
|
schema:
|
|
|
|
$ref: "#/components/schemas/User"
|
|
|
|
default:
|
|
|
|
$ref: "#/components/responses/DefaultResponse"
|
2021-12-19 15:30:21 +07:00
|
|
|
put:
|
2021-09-30 10:32:18 +07:00
|
|
|
description: Update self user.
|
|
|
|
tags: ["Users"]
|
|
|
|
operationId: modify user
|
2021-12-19 15:30:21 +07:00
|
|
|
x-go-middlewares: ["token"]
|
2021-09-30 10:32:18 +07:00
|
|
|
parameters:
|
2021-12-19 15:30:21 +07:00
|
|
|
- $ref: "#/components/parameters/Token"
|
2021-09-30 10:32:18 +07:00
|
|
|
requestBody:
|
|
|
|
description: Modified user information.
|
|
|
|
content:
|
|
|
|
application/json:
|
|
|
|
schema:
|
|
|
|
type: object
|
|
|
|
required:
|
|
|
|
- name
|
|
|
|
- grade_level
|
|
|
|
properties:
|
|
|
|
name:
|
|
|
|
type: string
|
|
|
|
grade_level:
|
|
|
|
type: integer
|
|
|
|
responses:
|
|
|
|
'200':
|
|
|
|
description: New user data
|
|
|
|
content:
|
|
|
|
application/json:
|
|
|
|
schema:
|
|
|
|
$ref: "#/components/schemas/User"
|
|
|
|
default:
|
|
|
|
$ref: "#/components/responses/DefaultResponse"
|
|
|
|
|
|
|
|
/users/email:
|
|
|
|
get:
|
|
|
|
description: |-
|
|
|
|
Get user info by email.
|
|
|
|
Requires admin to get user info not equal to the owner of the token.
|
|
|
|
tags: ["Users"]
|
|
|
|
operationId: get user by email
|
2021-12-19 15:30:21 +07:00
|
|
|
x-go-middlewares: ["token"]
|
2021-09-30 10:32:18 +07:00
|
|
|
parameters:
|
2021-12-19 15:30:21 +07:00
|
|
|
- $ref: "#/components/parameters/Token"
|
2021-09-30 10:32:18 +07:00
|
|
|
- name: email
|
|
|
|
in: query
|
|
|
|
description: User email.
|
|
|
|
required: true
|
|
|
|
schema:
|
|
|
|
type: string
|
|
|
|
format: email
|
|
|
|
responses:
|
|
|
|
'200':
|
|
|
|
description: User information.
|
|
|
|
content:
|
|
|
|
application/json:
|
|
|
|
schema:
|
|
|
|
$ref: "#/components/schemas/User"
|
|
|
|
default:
|
|
|
|
$ref: "#/components/responses/DefaultResponse"
|
2021-12-19 15:30:21 +07:00
|
|
|
put:
|
2021-09-30 10:32:18 +07:00
|
|
|
description: Update another user. Requires admin.
|
|
|
|
tags: ["Users"]
|
|
|
|
operationId: modify other user
|
2021-12-19 15:30:21 +07:00
|
|
|
x-go-middlewares: ["token", "admin_token"]
|
2021-09-30 10:32:18 +07:00
|
|
|
parameters:
|
|
|
|
- name: token
|
|
|
|
in: cookie
|
|
|
|
description: User authentication token.
|
|
|
|
required: true
|
|
|
|
schema:
|
|
|
|
type: string
|
|
|
|
- name: email
|
|
|
|
in: query
|
|
|
|
description: User email.
|
|
|
|
required: true
|
|
|
|
schema:
|
|
|
|
type: string
|
|
|
|
format: email
|
|
|
|
requestBody:
|
|
|
|
description: Modified user information.
|
|
|
|
content:
|
|
|
|
application/json:
|
|
|
|
schema:
|
|
|
|
type: object
|
|
|
|
required:
|
|
|
|
- name
|
|
|
|
- email
|
|
|
|
- picture
|
|
|
|
- grade_level
|
|
|
|
- teacher
|
|
|
|
- admin
|
|
|
|
properties:
|
|
|
|
name:
|
|
|
|
type: string
|
|
|
|
new_email:
|
|
|
|
type: string
|
|
|
|
format: email
|
|
|
|
picture:
|
|
|
|
type: string
|
|
|
|
format: uri
|
|
|
|
grade_level:
|
|
|
|
type: integer
|
|
|
|
teacher:
|
|
|
|
type: boolean
|
|
|
|
admin:
|
|
|
|
type: boolean
|
|
|
|
|
|
|
|
responses:
|
|
|
|
'200':
|
|
|
|
description: User information.
|
|
|
|
content:
|
|
|
|
application/json:
|
|
|
|
schema:
|
|
|
|
$ref: "#/components/schemas/User"
|
|
|
|
default:
|
|
|
|
$ref: "#/components/responses/DefaultResponse"
|
|
|
|
|
|
|
|
/users/all:
|
|
|
|
get:
|
2021-12-19 15:30:21 +07:00
|
|
|
description: Get all users. Requires admin.
|
2021-09-30 10:32:18 +07:00
|
|
|
tags: ["Users"]
|
|
|
|
operationId: get all users
|
2021-12-19 15:30:21 +07:00
|
|
|
x-go-middlewares: ["token", "admin_token"]
|
2021-09-30 10:32:18 +07:00
|
|
|
parameters:
|
2021-12-19 15:30:21 +07:00
|
|
|
- $ref: "#/components/parameters/Token"
|
2021-09-30 10:32:18 +07:00
|
|
|
responses:
|
|
|
|
'200':
|
|
|
|
description: All user information.
|
|
|
|
content:
|
|
|
|
application/json:
|
|
|
|
schema:
|
2021-12-19 15:30:21 +07:00
|
|
|
type: array
|
|
|
|
items:
|
|
|
|
$ref: "#/components/schemas/User"
|
2021-09-28 23:57:59 +07:00
|
|
|
default:
|
|
|
|
$ref: "#/components/responses/DefaultResponse"
|
|
|
|
|
|
|
|
components:
|
2021-12-19 15:30:21 +07:00
|
|
|
parameters:
|
|
|
|
Token:
|
|
|
|
name: token
|
|
|
|
in: cookie
|
|
|
|
description: User authentication token.
|
|
|
|
required: true
|
|
|
|
schema:
|
|
|
|
type: string
|
|
|
|
|
2021-09-28 23:57:59 +07:00
|
|
|
responses:
|
|
|
|
DefaultResponse:
|
2021-09-30 10:32:18 +07:00
|
|
|
description: Unexpected server error or invalid user input.
|
2021-09-28 23:57:59 +07:00
|
|
|
content:
|
|
|
|
application/json:
|
|
|
|
schema:
|
|
|
|
$ref: '#/components/schemas/Error'
|
|
|
|
|
|
|
|
schemas:
|
|
|
|
ConsentPage:
|
|
|
|
type: object
|
|
|
|
required:
|
|
|
|
- url
|
|
|
|
properties:
|
|
|
|
url:
|
|
|
|
type: string
|
|
|
|
format: uri
|
2021-09-30 10:32:18 +07:00
|
|
|
User:
|
|
|
|
type: object
|
|
|
|
required:
|
|
|
|
- id
|
|
|
|
- name
|
|
|
|
- email
|
|
|
|
- picture
|
|
|
|
- teacher
|
|
|
|
- admin
|
|
|
|
- created_at
|
|
|
|
properties:
|
|
|
|
id:
|
|
|
|
type: string
|
|
|
|
name:
|
|
|
|
type: string
|
|
|
|
email:
|
|
|
|
type: string
|
|
|
|
format: email
|
|
|
|
picture:
|
|
|
|
type: string
|
|
|
|
format: uri
|
|
|
|
grade_level:
|
|
|
|
type: integer
|
|
|
|
description: GradeLevel is only present if teacher is false.
|
|
|
|
teacher:
|
|
|
|
type: boolean
|
|
|
|
admin:
|
|
|
|
type: boolean
|
|
|
|
created_at:
|
|
|
|
type: string
|
|
|
|
format: date-time
|
2021-09-28 23:57:59 +07:00
|
|
|
|
|
|
|
Error:
|
|
|
|
type: object
|
|
|
|
required:
|
|
|
|
- message
|
|
|
|
properties:
|
|
|
|
message:
|
|
|
|
type: string
|