Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Backend API spec

Matt Boulanger edited this page Mar 21, 2020 · 2 revisions

Copy from here and paste into https://editor.swagger.io/ to view.

openapi: 3.0.3
info:
  title: CSM backend API
  version: 1.0.0
servers:
- url: http://localhost:5000
tags:
- name: user
- name: volunteer
- name: contact
- name: skills
paths:
  /users/reigster/:
    post:
      tags:
      - user
      summary: Register a new user
      operationId: userRegister
      requestBody:
        content:
          application/json:
           schema:
            $ref: '#/components/schemas/userRegister'
        required: true
      responses:
        400:
          description: Invalid information submitted
          content: {}
        409:
          description: User already exists
          content: {}
  /users/login/:
    post:
      tags:
      - user
      summary: Log into an account
      operationId: userLogin
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/userLogin'
      responses:
        200:
          description: Login successful
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/userLoginSuccess'
        400:
          description: Login failed
          content: {}
  /users/logout/:
    post:
      tags:
      - user
      summary: Log out of an account
      operationId: userLogout
      responses:
        200:
          description: Logout successful
          content: {}
        404:
          description: Not logged in
          content: {}
  /users/changepassword/:
    post:
      tags:
      - user
      summary: Change an account's password
      operationId: userChangePassword
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/userChangePassword'
      responses:
        200:
          description: Password changed successfully
          content: {}
        400:
          description: Failed to change password
          content: {}
  /users/profile/:
    get:
      tags:
      - user
      summary: Get the user's profile
      operationId: userProfileGet
      responses:
        200:
          description: Profile information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/userProfileGet'
    put:
      tags:
      - user
      summary: Update the user's profile
      operationId: userProfilePut
      responses:
        200:
          description: Information saved
          content: {}
        400:
          description: Failed to update
          content: {}
    delete:
      tags:
      - user
      summary: Delete the user's profile
      operationId: userProfileDelete
      responses:
        200:
          description: Profile deleted
          content: {}
  /volunteers/:
    get:
      tags:
      - volunteer
      summary: Get volunteers
      operationId: volunteersAllGet
      parameters:
        -
          name: skill
          in: query
          description: Skill to narrow search by
          required: false
          schema:
            type: string
      responses:
        200:
          description: Volunteers
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/volunteersAllGet'
  /volunteers/{id}:
    get:
      tags:
      - volunteer
      summary: Get volunteer by id
      operationId: volunteersGet
      parameters:
        -
          name: id
          in: path
          description: Volunteer id
          required: true
          schema:
            type: integer
            format: int64
      responses:
        200:
          description: Volunteer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/volunteersGet'
        404:
          description: Volunteer not found
          content: {}
  /contact/:
    get:
      tags:
      - contact
      summary: Get volunteers with contact info
      operationId: contactAllGet
      responses:
        200:
          description: Get volunteers with contact information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/volunteersAllGet'
  /contact/{id}:
    get:
      tags:
      - contact
      summary: Get volunteer with contact info by id
      operationId: contactGet
      parameters:
        -
          name: id
          in: path
          description: Volunteer id
          required: true
          schema:
            type: integer
            format: int64
      responses:
        200:
          description: Get volunteer with contact information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/volunteersGet'
        403:
          description: Insufficient permission
          content: {}
        404:
          description: Volunteer not found
          content: {}
  /contact/request/:
    post:
      tags:
      - contact
      summary: TBD
      operationId: contactRequestPost
      responses:
        200:
          description: ''
          content: {}
  /contact/accept/:
    post:
      tags:
      - contact
      summary: TBD
      operationId: contactAcceptPost
      responses:
        200:
          description: ''
          content: {}
  /skills/:
    get:
      tags:
      - skills
      summary: Get all skills
      operationId: skillsAllGet
      responses:
        200:
          description: List of skills
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/skillsAllGet'
  /skills/add/:
    post:
      tags:
      - skills
      summary: Add a skill
      operationId: skillsAddPost
      responses:
        202:
          description: Skill added
          content: {}
        409:
          description: Skill already exists
          content: {}
        403:
          description: Insufficient permission
          content: {}
components:
  schemas:
    userRegister:
      type: object
      properties:
        name:
          type: string
        password:
          type: string
    userLogin:
      type: object
      properties:
        name:
          type: string
        password:
          type: string
    userLoginSuccess:
      type: object
      properties:
        token:
          type: string
    userChangePassword:
      type: object
      properties:
        oldPassword:
          type: string
        newPassword:
          type: string
    userProfileGet:
      type: object
      properties:
        name:
          type: string
    volunteersAllGet:
      type: array
      items:
        $ref: '#/components/schemas/volunteersGet'
    volunteersGet:
      type: object
      properties:
        name:
          type: string
        email:
          type: string
        skills:
          type: array
          items:
            type: string
    skillsAllGet:
      type: array
      items:
        $ref: '#/components/schemas/skillsGet'
    skillsGet:
      type: object
      properties:
        name:
          type: string
  securitySchemes:
    csm_auth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: 'http://localhost:5000/users/login/'
          scopes: {}
    api_key:
      type: apiKey
      name: api_key
      in: header
Clone this wiki locally