From a5b26cda55085a14b7ac098ec662a88f72f731ab Mon Sep 17 00:00:00 2001 From: Joshua Garde Date: Mon, 30 Nov 2020 22:42:10 -0800 Subject: [PATCH] Documentation cleanup + fixes --- backend/api/event.py | 246 +++++++++++++-------------- backend/api/organization.py | 331 ++++++++++++++++++------------------ backend/api/user.py | 140 +++++++-------- 3 files changed, 354 insertions(+), 363 deletions(-) diff --git a/backend/api/event.py b/backend/api/event.py index d2f0852..50108b5 100644 --- a/backend/api/event.py +++ b/backend/api/event.py @@ -24,45 +24,45 @@ def get_all_published_event(): --- tags: - event - response: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - result: - type: array - items: - type: object - properties: - categories: - type: string - contact_id: - type: string - creator_id: - type: string - end_date: - type: string - event_id: - type: string - event_name: - type: string - info: - type: string - organization_id: - type: string - perks: - type: string - phase: - type: integer - start_date: - type: string - theme: - type: string + responses: + 200: + description: OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + result: + type: array + items: + type: object + properties: + categories: + type: string + contact_id: + type: string + creator_id: + type: string + end_date: + type: string + event_id: + type: string + event_name: + type: string + info: + type: string + organization_id: + type: string + perks: + type: string + phase: + type: integer + start_date: + type: string + theme: + type: string """ events = db.session.query(Event).filter(Event.phase == EventPhase.APPROVED).all() if events: @@ -80,49 +80,49 @@ def get_all_published_event(): @requires_auth def get_all_unpublished_event(org_id): """ - Show all unpublished events by organization (only chairman and admin allow to see the list) - --- - tags: - - event - response: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - result: - type: array - items: - type: object - properties: - categories: - type: string - contact_id: - type: string - creator_id: - type: string - end_date: - type: string - event_id: - type: string - event_name: - type: string - info: - type: string - organization_id: - type: string - perks: - type: string - phase: - type: integer - start_date: - type: string - theme: - type: string + Show all unpublished events by organization (only chairman and admin allow to see the list) + --- + tags: + - event + responses: + 200: + description: OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + result: + type: array + items: + type: object + properties: + categories: + type: string + contact_id: + type: string + creator_id: + type: string + end_date: + type: string + event_id: + type: string + event_name: + type: string + info: + type: string + organization_id: + type: string + perks: + type: string + phase: + type: integer + start_date: + type: string + theme: + type: string """ events = db.session.query(Event).filter(or_(Event.phase == EventPhase.INITIALIZED, Event.phase == EventPhase.ARCHIVED), @@ -211,22 +211,22 @@ def create_event(org_id): @requires_auth def delete_event(event_id): """ - Delete an unpublished event. - --- - tags: - - events - response: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - message: - type: string + Delete an unpublished event. + --- + tags: + - event + responses: + 200: + description: OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + message: + type: string """ # Verified the organization id existed or not event = Event.query.filter_by(event_id=event_id).first() @@ -290,31 +290,31 @@ def register_event(event_id): @requires_auth def get_all_participants(event_id): """ - Show all participants of a specific event. - --- - tags: - - event - response: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - message: - type: string - participants: - type: array - items: - type: object - properties: - name: - type: String - user_id: - type: string + Show all participants of a specific event. + --- + tags: + - event + responses: + 200: + description: OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + message: + type: string + participants: + type: array + items: + type: object + properties: + name: + type: string + user_id: + type: string """ registers = Registration.query.filter_by(event_id=event_id).all() if not registers or registers is None: diff --git a/backend/api/organization.py b/backend/api/organization.py index 83dde88..24de0f6 100644 --- a/backend/api/organization.py +++ b/backend/api/organization.py @@ -16,33 +16,33 @@ @app.route('/organization/list', methods=['GET']) def get_all_org(): """ - Return all organizations - --- - tags: - - organization - response: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - result: - type: array - items: - type: object - properties: - categories: - type: string - contact_id: - type: string - org_name: - type: string - organization: - type: string + Return all organizations + --- + tags: + - organization + responses: + 200: + description: OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + result: + type: array + items: + type: object + properties: + categories: + type: string + contact_id: + type: string + org_name: + type: string + organization: + type: string """ organizations = Organization.query.all() organizations_schema = OrganizationSchema(many=True) @@ -56,47 +56,47 @@ def get_all_published_events(org_id): """ Show all published events of an events --- - tags: - - event - response: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - result: - type: array - items: - type: object - properties: - categories: - type: string - contact_id: - type: string - creator_id: - type: string - end_date: - type: string - event_id: - type: string - event_name: - type: string - info: - type: string - organization_id: - type: string - perks: - type: string - phase: - type: integer - start_date: - type: string - theme: - type: string + tags: + - organization + responses: + 200: + description: OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + result: + type: array + items: + type: object + properties: + categories: + type: string + contact_id: + type: string + creator_id: + type: string + end_date: + type: string + event_id: + type: string + event_name: + type: string + info: + type: string + organization_id: + type: string + perks: + type: string + phase: + type: integer + start_date: + type: string + theme: + type: string """ # Verify the organize exists. organization = Organization.query.filter_by(organization_id=org_id).first() @@ -122,34 +122,34 @@ def get_org_info(org_id): Show an organization's details --- tags: - - event - response: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - board: - type: array - item: - type: object - properties: - name: - type: string - role: - type: string - user_id: - type: string - categories: - type: string - org_name: - type: string - organization_id: - type: string - success: - type: boolean + - organization + responses: + 200: + description: OK + content: + application/json: + schema: + type: object + properties: + board: + type: array + item: + type: object + properties: + name: + type: string + role: + type: string + user_id: + type: string + categories: + type: string + org_name: + type: string + organization_id: + type: string + success: + type: boolean """ # Verify the organize exists. organization = Organization.query.filter_by(organization_id=org_id).first() @@ -209,55 +209,47 @@ def add_org(): Create a new organization --- tags: - organization - parameter: - - in: body - name: organization - description: new organization - require: true + - organization + parameters: + - in: body + name: body + required: true + schema: + required: + - org_name + - categories + - contact + properties: + org_name: + type: string + categories: + type: string + contact: + type: object + properties: + address: + type: string + state: + type: string + zipcode: + type: integer + country: + type: string + dob: + type: string + description: An ISO 8601 formatted datetime string + responses: + 200: + description: OK + content: + application/json: schema: - type: object - required: - - org_name - - categories - - contact - properties: - org_name: - type: string - categories: - type: string - contact: - type: object - required: - - address - - state - - zipcode - - country - - dob - properties: - address: - type: string - state: - type: string - zipcode - type: integer - country: - type: string - dob: - type: string - description: An ISO 8601 formatted datetime string - response: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - message: - type: string + type: object + properties: + success: + type: boolean + message: + type: string """ sessionObj = request.session @@ -295,19 +287,19 @@ def register_org(org_id): Register an organization. --- tags: - - organization - response: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - message: - type: string + - organization + responses: + 200: + description: OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + message: + type: string """ organization = Organization.query.filter_by(organization_id=org_id).first() if organization is None: @@ -337,19 +329,18 @@ def unregister_org(org_id): Unregister an organization or chairman resign --- tags: - - organization - parameter: - - in: body - name: email - description: required if the user is Chairman - required: false - schema: - required: - - email - properties: - email: - type: string - response: + - organization + parameters: + - in: body + name: email + required: false + schema: + required: + - email + properties: + email: + type: string + responses: 200: description: OK content: diff --git a/backend/api/user.py b/backend/api/user.py index e09c6c2..8c3669f 100644 --- a/backend/api/user.py +++ b/backend/api/user.py @@ -26,24 +26,24 @@ def login(email, password, **kwargs): tags: - user responses: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - message: - type: string - session: - type: object - properties: - token: - type: string - expires: - type: string + 200: + description: OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + message: + type: string + session: + type: object + properties: + token: + type: string + expires: + type: string ''' try: @@ -79,24 +79,24 @@ def signup(name, email, password, **kwargs): tags: - user responses: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - message: - type: string - session: - type: object - properties: - token: - type: string - expires: - type: string + 200: + description: OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + message: + type: string + session: + type: object + properties: + token: + type: string + expires: + type: string ''' # Validate name @@ -199,29 +199,29 @@ def get_me(): tags: - user responses: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - message: - type: string - user: - type: object - properties: - name: - type: string - roles: - type: object - properties: - organization_id: - type: string - role: - type: string + 200: + description: OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + message: + type: string + user: + type: object + properties: + name: + type: string + roles: + type: object + properties: + organization_id: + type: string + role: + type: string ''' user_data = request.user.dump() @@ -239,17 +239,17 @@ def delete_me(password, **kwargs): tags: - user responses: - 200: - description: OK - content: - application/json: - schema: - type: object - properties: - success: - type: boolean - message: - type: string + 200: + description: OK + content: + application/json: + schema: + type: object + properties: + success: + type: boolean + message: + type: string ''' user = request.user