Swagger correction

This commit is contained in:
riccardo
2021-09-05 20:36:39 +02:00
parent c8f520137d
commit 13f6cd2d14
3 changed files with 21 additions and 169 deletions

View File

@@ -32,7 +32,7 @@ class CouponController extends Controller
* path="/get-coupon",
* operationId="/get-coupon",
* tags={"getCoupon"},
* security={ {"bearer": {} }},
* security={ {"bearer_token": {} }},
* @OA\Parameter(
* name="brand_id",
* in="query",
@@ -43,6 +43,16 @@ class CouponController extends Controller
* @OA\Response(
* response="200",
* description="Returns the coupon code",
* content={
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(
* example={
* "data": {"code": "d4r6o9sd46i.5i4is57u3"}
* }
* )
* )
* }
* ),
* @OA\Response(
* response="401",
@@ -102,11 +112,11 @@ class CouponController extends Controller
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*
* @OA\Get(
* @OA\Post(
* path="/generate-coupons",
* operationId="/generate-coupons",
* tags={"generateCoupons"},
* security={ {"bearer": {} }},
* security={ {"bearer_token": {} }},
* @OA\Parameter(
* name="quantity",
* in="query",
@@ -118,11 +128,11 @@ class CouponController extends Controller
* name="prefix",
* in="query",
* description="Prefix to be used in the coupon codes.",
* required=true,
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Response(
* response="200",
* response="201",
* description="Success.",
* @OA\JsonContent(
* @OA\Property(property="message", type="string", example="Coupon code(s) generation job sent.")
@@ -164,6 +174,6 @@ class CouponController extends Controller
return response()->json([
'message' => 'Coupon code(s) generation job sent.'
], 200);
], 201);
}
}

View File

@@ -107,13 +107,13 @@ return [
| Examples of Security definitions
|--------------------------------------------------------------------------
*/
/*
'api_key_security_example' => [ // Unique name of security
'bearer_token' => [ // Unique name of security
'type' => 'apiKey', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
'description' => 'A short description for security scheme',
'name' => 'api_key', // The name of the header or query parameter to be used.
'description' => 'Enter token in format (Bearer <token>)',
'name' => 'Authorization', // The name of the header or query parameter to be used.
'in' => 'header', // The location of the API key. Valid values are "query" or "header".
],
/*
'oauth2_security_example' => [ // Unique name of security
'type' => 'oauth2', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
'description' => 'A short description for oauth2 security scheme.',

View File

@@ -1,159 +1 @@
{
"openapi": "3.0.0",
"info": {
"title": "Example API",
"contact": {
"name": "Support Team",
"email": "support@example.com"
},
"version": "1.0"
},
"paths": {
"/get-coupon": {
"get": {
"tags": [
"getCoupon"
],
"summary": "Retrieve a coupon code for the user, based on the selected brand, if available.",
"operationId": "/get-coupon",
"parameters": [
{
"name": "brand_id",
"in": "query",
"description": "ID of the brand for which the coupon is requested.",
"required": true,
"schema": {
"type": "integer"
}
}
],
"responses": {
"200": {
"description": "Returns the coupon code"
},
"401": {
"description": "Error: Not authenticated.",
"content": {
"application/json": {
"schema": {
"properties": {
"message": {
"type": "string",
"example": "Token expired."
}
},
"type": "object"
}
}
}
},
"403": {
"description": "Error: Not authorized.",
"content": {
"application/json": {
"schema": {
"properties": {
"message": {
"type": "string",
"example": "Not authorized."
}
},
"type": "object"
}
}
}
}
},
"security": [
{
"bearer": []
}
]
}
},
"/generate-coupons": {
"get": {
"tags": [
"generateCoupons"
],
"summary": "Generates coupon codes for a brand.",
"operationId": "/generate-coupons",
"parameters": [
{
"name": "quantity",
"in": "query",
"description": "Quantity of coupons to be generated.",
"required": true,
"schema": {
"type": "integer"
}
},
{
"name": "prefix",
"in": "query",
"description": "Prefix to be used in the coupon codes.",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Success.",
"content": {
"application/json": {
"schema": {
"properties": {
"message": {
"type": "string",
"example": "Coupon code(s) generation job sent."
}
},
"type": "object"
}
}
}
},
"401": {
"description": "Error: Not authenticated.",
"content": {
"application/json": {
"schema": {
"properties": {
"message": {
"type": "string",
"example": "Token expired."
}
},
"type": "object"
}
}
}
},
"403": {
"description": "Error: Not authorized.",
"content": {
"application/json": {
"schema": {
"properties": {
"message": {
"type": "string",
"example": "Not authorized."
}
},
"type": "object"
}
}
}
}
},
"security": [
{
"bearer": []
}
]
}
}
}
}
{"openapi":"3.0.0","info":{"title":"Example API","contact":{"name":"Support Team","email":"support@example.com"},"version":"1.0"},"paths":{"\/get-coupon":{"get":{"tags":["getCoupon"],"summary":"Retrieve a coupon code for the user, based on the selected brand, if available.","operationId":"\/get-coupon","parameters":[{"name":"brand_id","in":"query","description":"ID of the brand for which the coupon is requested.","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Returns the coupon code","content":{"application\/json":{"schema":{"example":{"data":{"code":"d4r6o9sd46i.5i4is57u3"}}}}}},"401":{"description":"Error: Not authenticated.","content":{"application\/json":{"schema":{"properties":{"message":{"type":"string","example":"Token expired."}},"type":"object"}}}},"403":{"description":"Error: Not authorized.","content":{"application\/json":{"schema":{"properties":{"message":{"type":"string","example":"Not authorized."}},"type":"object"}}}}},"security":[{"bearer_token":[]}]}},"\/generate-coupons":{"post":{"tags":["generateCoupons"],"summary":"Generates coupon codes for a brand.","operationId":"\/generate-coupons","parameters":[{"name":"quantity","in":"query","description":"Quantity of coupons to be generated.","required":true,"schema":{"type":"integer"}},{"name":"prefix","in":"query","description":"Prefix to be used in the coupon codes.","required":false,"schema":{"type":"string"}}],"responses":{"201":{"description":"Success.","content":{"application\/json":{"schema":{"properties":{"message":{"type":"string","example":"Coupon code(s) generation job sent."}},"type":"object"}}}},"401":{"description":"Error: Not authenticated.","content":{"application\/json":{"schema":{"properties":{"message":{"type":"string","example":"Token expired."}},"type":"object"}}}},"403":{"description":"Error: Not authorized.","content":{"application\/json":{"schema":{"properties":{"message":{"type":"string","example":"Not authorized."}},"type":"object"}}}}},"security":[{"bearer_token":[]}]}}},"components":{"securitySchemes":{"bearer_token":{"type":"apiKey","description":"Enter token in format (Bearer <token>)","name":"Authorization","in":"header"}}}}