# swagger api接口调用指南
系统访问swagger API地址:[https://demo.mallsuite.cn/api/doc.html](https://demo.mallsuite.cn/api/doc.html)
#### 一:gateway路由配置
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_74236542953c23675b269b755a866872_r.png "null")
上图为代码中的gateway配置:
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_4150077fd0e8c54c35d65a2a3c1b15cb_r.png "null")
以下为gateway具体配置信息:
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_6b32223b50b3540292e121b253cdacb5_r.png "null")
gateway访问端口号: 8201
例如, /mall-account/admin/account/account-user-base/info 通过gateway 默认访问地址为:ip:8201/admin/account/account-user-base/info {去掉mall-account, gateway路径配置决定了}
线上,配置的域名访问的时候,gateway为80端口,并做了一个网址代理映射,未加nginx代理前线上访问地址为:[https://demo.mallsuite.cn/admin/account/account-user-base/info](https://demo.mallsuite.cn/admin/account/account-user-base/info)
nginx配置截图:
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_33f65b2213cd933ec3b05cefbf2fa48b_r.png "null")
线上配置代理后,在域名前,配置了一个api,所以[https://demo.mallsuite.cn/admin/account/account-user-base/info](https://demo.mallsuite.cn/admin/account/account-user-base/info)访问应该改为:[https://demo.mallsuite.cn/api/admin/account/account-user-base/info](https://demo.mallsuite.cn/api/admin/account/account-user-base/info)
#### 二、调用演示说明
线上调用的位置为: 域名/api, 这个是访问到我们线上演示版gateway的:
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_63f1d216e7f8908c373fbdc93b14092d_r.png "null")
可以通过此处,设置默认的gateway方位地址, 不需要每次都修改单独接口网址了。另外,调用接口需要鉴权,我们可以调用获得token的接口,如下图:
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_c198218176b817408b5874c42828921b_r.png "null")
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_a74ee2b5e796371d3ffbcddceea8da89_r.png "null")
下图为代码中gateway路径配置:
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_6aad68b50b39688fdc59c71031515ec1_r.png "null")
请求成功后返回的结果如图所示:
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_9607a32ea81a1ba0430c05afc3ca276d_r.png "null")
全局设置 Authorization header,注意:设置token的时候一定要加上Bearer加个空格与token分开,下图所示:
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_ef3c75410ece5eab0309d744d049b647_r.png "null")
上图这儿设置后,刷新下页面,则所有微服务接口,都会自带设置好token。
#### 三、实际使用案例
例如,去获取当前用户信息, 切换到mall-account服务接口如图所示:
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_370cbf23e7508d105fe70f7767133ceb_r.png "null")
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_e7c29006444038fcaf3f17d010ae1e1d_r.png "null")
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_028c1ee05c14d2b1f3012f1ef3f0bd9a_r.png "null")
![](https://docs.suteshop.com/uploads/shopsuite-java/images/m_5b6b0f8a9434c74d18c2b7a0d7a3f5e7_r.png "null")
至此,线上swagger api演示完成