From a3fc6895e866d27a0f7f53ca60114ce590fd52da Mon Sep 17 00:00:00 2001 From: Fairuz Date: Tue, 29 Jun 2021 11:18:45 +0800 Subject: [PATCH] Fixes for swagger to add bearer token to header --- resources/views/swagger/index.blade.php | 12 ++++++------ resources/views/swagger/json.blade.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/resources/views/swagger/index.blade.php b/resources/views/swagger/index.blade.php index 3f32ead2..982c1ae1 100644 --- a/resources/views/swagger/index.blade.php +++ b/resources/views/swagger/index.blade.php @@ -51,12 +51,12 @@ ], responseInterceptor: function (response) { - if (response.obj.data) { - console.log('Response'); - console.log(response.obj); - if (response.obj.data.token) { - console.log("Auth Token: " + response.obj.data.token); - const token = response.obj.data.token; + console.log('Response'); + console.log(response.obj); + if (response.obj.payload) { + if (response.obj.payload.access_token) { + const token = response.obj.payload.access_token; + console.log("Auth Token: " + token); localStorage.setItem("token", token) } return response; diff --git a/resources/views/swagger/json.blade.php b/resources/views/swagger/json.blade.php index 3c627d71..d7efb596 100644 --- a/resources/views/swagger/json.blade.php +++ b/resources/views/swagger/json.blade.php @@ -1 +1 @@ -{"swagger":"2.0","info":{"description":"Shipping Portal to manage parcel","version":"1.0.0","title":"Shipping Portal"},"host":"{{request()->getHttpHost()}}","basePath":"\/api\/v1","tags":[{"name":"Account","description":"Endpoints related to user module, e.g. login, register."},{"name":"Address","description":"Endpoints related t address module, e.g. create, district."}],"schemes":["http","https"],"paths":{"\/account\/registration\/registration":{"post":{"tags":["Account"],"produces":["application\/json"],"summary":"Register user into the system","description":"","parameters":[{"name":"name","in":"query","description":"The name of user","required":true,"type":"string"},{"name":"email","in":"query","description":"The email for login","required":true,"type":"string","format":"email"},{"name":"password","in":"query","description":"The password for login","required":true,"type":"string","format":"password"},{"name":"password_confirmation","in":"query","description":"The confirmation password for login","required":true,"type":"string","format":"password"},{"name":"type","in":"query","description":"Account type","required":true,"default":3,"type":"integer"},{"name":"phone","in":"query","description":"Contact phone number","required":true,"type":"string"},{"name":"contact_email","in":"query","description":"Contact email","required":true,"type":"string"},{"name":"company_name","in":"query","description":"The company name - if not defined , name of user will save as the company name ","required":false,"type":"string"},{"name":"wechat_id","in":"query","description":"Contact Wechat id","required":false,"type":"string"}],"responses":{"200":{"description":"successful operation","headers":{"X-Expires-After":{"type":"string","format":"date-time","description":"date in UTC when token expires"},"X-Rate-Limit":{"type":"integer","format":"int32","description":"calls per hour allowed by the user"}},"schema":{"type":"string"}},"400":{"description":"Invalid username\/password supplied"}}}},"\/account\/authentication\/login\/attempt":{"post":{"tags":["Account"],"produces":["application\/json"],"summary":"Logs user into the system","description":"","parameters":[{"name":"email","in":"query","description":"The user name for login","required":true,"type":"string"},{"name":"password","in":"query","description":"The password for login in clear text","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","headers":{"X-Expires-After":{"type":"string","format":"date-time","description":"date in UTC when token expires"},"X-Rate-Limit":{"type":"integer","format":"int32","description":"calls per hour allowed by the user"}},"schema":{"type":"string"}},"400":{"description":"Invalid username\/password supplied"}}}},"\/account\/authentication\/logout":{"get":{"tags":["Account"],"summary":"Logs out current logged in user session","description":"","operationId":"logoutUser","produces":["application\/json","application\/xml"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}},"\/address\/id\/show":{"get":{"tags":["Address"],"summary":"Logs out current logged in user session","description":"","operationId":"logoutUser","produces":["application\/json","application\/xml"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}},"\/address\/create":{"post":{"tags":["Address"],"summary":"Logs out current logged in user session","description":"","operationId":"logoutUser","produces":["application\/json","application\/xml"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}},"\/address\/update\/id":{"put":{"tags":["Address"],"summary":"Logs out current logged in user session","description":"","operationId":"logoutUser","produces":["application\/json","application\/xml"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}},"\/address\/delete\/id":{"delete":{"tags":["Address"],"summary":"Logs out current logged in user session","description":"","operationId":"logoutUser","produces":["application\/json","application\/xml"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}}},"securityDefinitions":{"Authorization":{"type":"apiKey","name":"api_key","in":"header"},"petstore_auth":{"type":"oauth2","authorizationUrl":"https:\/\/petstore.swagger.io\/oauth\/authorize","flow":"implicit","scopes":{"read:pets":"read your pets","write:pets":"modify pets in your account"}}},"definitions":{"ApiResponse":{"type":"object","properties":{"code":{"type":"integer","format":"int32"},"title":{"type":"string"},"message":{"type":"string"},"payload":{"type":"object"}}}}} \ No newline at end of file +{"swagger":"2.0","info":{"description":"Shipping Portal to manage parcel","version":"1.0.0","title":"Shipping Portal"},"host":"{{request()->getHttpHost()}}","basePath":"/api/v1","tags":[{"name":"Account","description":"Endpoints related to user module, e.g. login, register."},{"name":"Address","description":"Endpoints related t address module, e.g. create, district."}],"schemes":["http","https"],"paths":{"/account/registration/registration":{"post":{"tags":["Account"],"produces":["application/json"],"summary":"Register user into the system","description":"","parameters":[{"name":"name","in":"query","description":"The name of user","required":true,"type":"string"},{"name":"email","in":"query","description":"The email for login","required":true,"type":"string","format":"email"},{"name":"password","in":"query","description":"The password for login","required":true,"type":"string","format":"password"},{"name":"password_confirmation","in":"query","description":"The confirmation password for login","required":true,"type":"string","format":"password"},{"name":"type","in":"query","description":"Account type","required":true,"default":3,"type":"integer"},{"name":"phone","in":"query","description":"Contact phone number","required":true,"type":"string"},{"name":"contact_email","in":"query","description":"Contact email","required":true,"type":"string"},{"name":"company_name","in":"query","description":"The company name - if not defined , name of user will save as the company name ","required":false,"type":"string"},{"name":"wechat_id","in":"query","description":"Contact Wechat id","required":false,"type":"string"}],"responses":{"200":{"description":"successful operation","headers":{"X-Expires-After":{"type":"string","format":"date-time","description":"date in UTC when token expires"},"X-Rate-Limit":{"type":"integer","format":"int32","description":"calls per hour allowed by the user"}},"schema":{"type":"string"}},"400":{"description":"Invalid username/password supplied"}}}},"/account/authentication/login/attempt":{"post":{"tags":["Account"],"produces":["application/json"],"summary":"Logs user into the system","description":"","parameters":[{"name":"email","in":"query","description":"The user name for login","required":true,"type":"string"},{"name":"password","in":"query","description":"The password for login in clear text","required":true,"type":"string"}],"responses":{"200":{"description":"successful operation","headers":{"X-Expires-After":{"type":"string","format":"date-time","description":"date in UTC when token expires"},"X-Rate-Limit":{"type":"integer","format":"int32","description":"calls per hour allowed by the user"}},"schema":{"type":"string"}},"400":{"description":"Invalid username/password supplied"}}}},"/account/authentication/logout":{"get":{"tags":["Account"],"summary":"Logs out current logged in user session","description":"","operationId":"logoutUser","produces":["application/json","application/xml"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}},"/address/id/show":{"get":{"tags":["Address"],"summary":"Logs out current logged in user session","description":"","operationId":"logoutUser","produces":["application/json","application/xml"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}},"/address/create":{"post":{"tags":["Address"],"summary":"Logs out current logged in user session","description":"","operationId":"logoutUser","produces":["application/json","application/xml"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}},"/address/update/id":{"put":{"tags":["Address"],"summary":"Logs out current logged in user session","description":"","operationId":"logoutUser","produces":["application/json","application/xml"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}},"/address/delete/id":{"delete":{"tags":["Address"],"summary":"Logs out current logged in user session","description":"","operationId":"logoutUser","produces":["application/json","application/xml"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}},"/account/user/list":{"get":{"tags":["Account"],"summary":"Logs out current logged in user session","description":"","operationId":"userList","produces":["application/json","application/xml"],"parameters":[],"responses":{"default":{"description":"successful operation"}}}}},"securityDefinitions":{"Authorization":{"type":"apiKey","name":"api_key","in":"header"},"petstore_auth":{"type":"oauth2","authorizationUrl":"https://petstore.swagger.io/oauth/authorize","flow":"implicit","scopes":{"read:pets":"read your pets","write:pets":"modify pets in your account"}}},"definitions":{"ApiResponse":{"type":"object","properties":{"code":{"type":"integer","format":"int32"},"title":{"type":"string"},"message":{"type":"string"},"payload":{"type":"object"}}}}} \ No newline at end of file