Work on swag documentation

This commit is contained in:
Thastertyn committed 2024-03-13 13:43:34 +01:00
1 parent 0f7d69899a
commit f259aa3993
13 files changed
+115 -55

No files matched your search

+11 -15
View File
@@ -1,13 +1,8 @@
show_cart_swagger = {
"tags": ["Cart"],
"parameters":
"security":
[
{
"name": "Authorization",
"in": "header",
"type": "string",
"required": True
}
{"JWT": []}
],
"responses":
{
@@ -45,24 +40,25 @@ show_cart_swagger = {
add_to_cart_swagger ={
"tags": ["Cart"],
"security":
[
{"JWT": []}
],
"parameters":
[
{
"name": "Authorization",
"in": "header",
"type": "string",
"required": True
},
{
"name": "product_id",
"description": "ID of product to add to cart.",
"in": "path",
"type": "int",
"required": True
},
{
"name": "count",
"description": "Count of the products. If not provided, defaults to 1",
"in": "query",
"type": "int",
"default": 1,
"minimum": 1,
"required": False
}
],
@@ -74,7 +70,7 @@ add_to_cart_swagger ={
},
"400":
{
"description": "Incorrect usage. For example id of product not found or product count < 1"
"description": "Causes:\n- Count is < 1"
}
}
}
+18
View File
@@ -0,0 +1,18 @@
main_swagger = {
"info": {
"title": "Shop API",
"version": "0.1",
"description": "Simple shop API using flask and co.\nFeatures include:\n- Not working\n- Successful registration of users\n- Adding items to cart\n- I don't know",
},
"host": "localhost:1236",
"schemes": "http",
"securityDefinitions": {
"JWT": {
"type": "apiKey",
"scheme": "bearer",
"name": "Authorization",
"in": "header",
"description": "JWT Authorization header using the Bearer scheme.\n*Make sure to prefix the token with **Bearer**!*"
}
}
}
-23
View File
@@ -1,23 +0,0 @@
get_products_swagger = {
"paths": {
"/get": {
"get": {
"summary": "Get products",
"responses": {
"200": {
"description": "Successfully retrieved products",
"schema": {
"type": "object",
"properties": {
"products": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "int"}, "name": {"type": "string"}, "price": {"type": "float"}}}}
}
}
},
"400": {
"description": "Bad request"
}
}
}
}
}
}
+21
View File
@@ -0,0 +1,21 @@
get_products_swagger = {
"methods": ["GET"],
"tags": ["Products"],
"parameters": [
],
"responses":
{
"200":
{
"description": "Get a page of products",
"schema":
{
"type": "object",
"properties": {
"message": {"type": "string", "example": "Hello, Flask!"}
}
}
}
}
}
+3 -5
View File
@@ -1,8 +1,5 @@
main_swagger = {
root_swagger = {
"methods": ["GET"],
"parameters": [
],
"responses":
{
"200":
@@ -11,7 +8,8 @@ main_swagger = {
"schema":
{
"type": "object",
"properties": {
"properties":
{
"message": {"type": "string", "example": "Hello, Flask!"}
}
}
View File
Whitespace-only changes.
+45
View File
@@ -0,0 +1,45 @@
login_swagger = {
"methods": ["POST"],
"tags": ["User"],
"description": "Logs in using username and password and returns a JWT token for further authorization of requests.\n**The token is valid for 1 hour**",
"parameters":
[
{
"in": "body",
"name": "body",
"description": "Username and password payload",
"required": True,
"schema":
{
"type": "object",
"properties":
{
"username": {"type": "string", "example": "mycoolusername"},
"password": {"type": "string", "example": "MyStrongPassword123"}
}
}
}
],
"responses":
{
"200":
{
"description": "Returns a fresh token",
"schema":
{
"type": "object",
"properties": {
"token": {"type": "string", "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTcxMDMyMjkyOCwianRpIjoiZDFhYzQxZDktZjA4NC00MmYzLThlMWUtZWFmZjJiNGU1MDAyIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6MjMwMDEsIm5iZiI6MTcxMDMyMjkyOCwiZXhwIjoxNzEwMzI2NTI4fQ.SW7LAi1j5vDOEIvzeN-sy0eHPP9PFJFkXYY029O35w0"}
}
}
},
"400":
{
"description": "Possible causes:\n- Missing username or password from request.\n- Nonexistent username"
},
"401":
{
"description": "Password is incorrect"
}
}
}