Created
November 30, 2021 11:18
-
-
Save henrygermany/8ad580a5b56e8eaae3bb1da2114123e4 to your computer and use it in GitHub Desktop.
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
{ | |
"openapi": "3.0.3", | |
"info": { | |
"title": "SpoDa Internal REST API", | |
"description": "Serves as a contract between the Java backend and flutter/web frontend. Implemented with javax.ws.rs.", | |
"version": "0.0.1" | |
}, | |
"components": { | |
"schemas": { | |
"Users": { | |
"type": "array", | |
"items": { | |
"$ref": "#/components/schemas/User" | |
} | |
}, | |
"User": { | |
"type": "object", | |
"properties": { | |
"username": { | |
"type": "string" | |
}, | |
"email": { | |
"type": "string" | |
}, | |
"firstname": { | |
"type": "string" | |
}, | |
"lastname": { | |
"type": "string" | |
}, | |
"street": { | |
"type": "string" | |
}, | |
"streetNr": { | |
"type": "integer" | |
}, | |
"zip": { | |
"type": "string" | |
}, | |
"city": { | |
"type": "string" | |
} | |
} | |
}, | |
"UserWithPassword": { | |
"allOf": [ | |
{ | |
"$ref": "#/components/schemas/User" | |
}, | |
{ | |
"type": "object", | |
"properties": { | |
"password": { | |
"type": "string" | |
} | |
} | |
} | |
] | |
}, | |
"Groups": { | |
"type": "array", | |
"items": { | |
"$ref": "#/components/schemas/Group" | |
} | |
}, | |
"Group": { | |
"type": "object", | |
"properties": { | |
"groupName": { | |
"type": "string" | |
}, | |
"groupId": { | |
"type": "number" | |
}, | |
"adminId": { | |
"type": "number" | |
} | |
} | |
}, | |
"Memberships": { | |
"type": "array", | |
"items": { | |
"$ref": "#/components/schemas/Membership" | |
} | |
}, | |
"Membership": { | |
"type": "object", | |
"properties": { | |
"groupId": { | |
"type": "number" | |
}, | |
"userId": { | |
"type": "number" | |
}, | |
"invitationPending": { | |
"type": "boolean" | |
} | |
} | |
}, | |
"Login": { | |
"type": "object", | |
"properties": { | |
"username": { | |
"type": "string" | |
}, | |
"password": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
}, | |
"servers": [ | |
{ | |
"url": "https://localhost:9090/spoda" | |
} | |
], | |
"paths": { | |
"/auth/login": { | |
"post": { | |
"summary": "Login user", | |
"requestBody": { | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/Login" | |
} | |
} | |
} | |
}, | |
"responses": { | |
"201": { | |
"description": "User logged in successfully.", | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"token": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
} | |
}, | |
"400": { | |
"description": "Either the user did not specify all required fields to login or the given password was wrong." | |
} | |
} | |
} | |
}, | |
"/auth/logout": { | |
"delete": { | |
"summary": "Logout user", | |
"responses": { | |
"204": { | |
"description": "User logged out successfully." | |
} | |
} | |
} | |
}, | |
"/users": { | |
"get": { | |
"summary": "Get all users", | |
"responses": { | |
"200": { | |
"description": "OK.", | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/Users" | |
} | |
} | |
} | |
} | |
} | |
}, | |
"post": { | |
"summary": "Create a new user", | |
"requestBody": { | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/UserWithPassword" | |
} | |
} | |
} | |
}, | |
"responses": { | |
"201": { | |
"description": "User was successfully created." | |
}, | |
"400": { | |
"description": "Client did not specify all fields necessary to create a user or some fields were malformed." | |
} | |
} | |
} | |
}, | |
"/users/{id}": { | |
"get": { | |
"parameters": [ | |
{ | |
"name": "id", | |
"in": "path", | |
"required": true, | |
"schema": { | |
"type": "number" | |
} | |
} | |
], | |
"summary": "Get user with id `id`", | |
"responses": { | |
"200": { | |
"description": "OK.", | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/User" | |
} | |
} | |
} | |
}, | |
"404": { | |
"description": "User with id `id` was not found." | |
} | |
} | |
} | |
}, | |
"/users/{id}/memberships": { | |
"get": { | |
"parameters": [ | |
{ | |
"name": "id", | |
"in": "path", | |
"required": true, | |
"schema": { | |
"type": "number" | |
} | |
} | |
], | |
"summary": "Get all memberships of user with id `id`", | |
"responses": { | |
"200": { | |
"description": "OK.", | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/Memberships" | |
} | |
} | |
} | |
} | |
} | |
}, | |
"put": { | |
"parameters": [ | |
{ | |
"name": "id", | |
"in": "path", | |
"required": true, | |
"schema": { | |
"type": "number" | |
} | |
} | |
], | |
"summary": "Update membership of user with id `id`", | |
"responses": { | |
"200": { | |
"description": "OK.", | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/Membership" | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"/groups": { | |
"get": { | |
"description": "Get all groups.", | |
"responses": { | |
"200": { | |
"description": "OK.", | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/Groups" | |
} | |
} | |
} | |
} | |
} | |
}, | |
"post": { | |
"description": "Create a new group.", | |
"requestBody": { | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"groupName": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
} | |
}, | |
"responses": { | |
"201": { | |
"description": "Group was successfully created." | |
}, | |
"400": { | |
"description": "Client did not specify all fields necessary to create a user or some fields were malformed." | |
} | |
} | |
} | |
}, | |
"/groups/{id}": { | |
"get": { | |
"parameters": [ | |
{ | |
"name": "id", | |
"in": "path", | |
"required": true, | |
"schema": { | |
"type": "number" | |
} | |
} | |
], | |
"description": "Get group with id `id`", | |
"responses": { | |
"200": { | |
"description": "OK.", | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/Group" | |
} | |
} | |
} | |
}, | |
"404": { | |
"description": "Group with id `id` was not found." | |
} | |
} | |
}, | |
"delete": { | |
"parameters": [ | |
{ | |
"name": "id", | |
"in": "path", | |
"required": true, | |
"schema": { | |
"type": "number" | |
} | |
} | |
], | |
"description": "Delete group with id `id`", | |
"responses": { | |
"201": { | |
"description": "Group was successfully deleted." | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment