Fixes for swagger to add bearer token to header

This commit is contained in:
Fairuz
2021-06-29 11:18:45 +08:00
parent 6bfcb11bb2
commit a3fc6895e8
2 changed files with 7 additions and 7 deletions
+6 -6
View File
@@ -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;
+1 -1
View File
@@ -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"}}}}}
{"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"}}}}}