# springboot_swagger **Repository Path**: cfmCode/springboot_swagger ## Basic Information - **Project Name**: springboot_swagger - **Description**: 本仓库主要是springboot2+swagger2进行环境搭建,主要用于后续一些OpenAPI研究学习 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-06-28 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 本项目主要用于OpenAPI等学习模拟使用 # RESTful API rest架构,从个人角度理解,核心做了两件事情 - 资源定位 - 资源操作 其实从REST的定义中就能看出来,表述层对应的就是描述资源的位置(资源定位),状态转移就是对资源的状态进行变更操作(增删改查) >看URI就知道需要什么资源 > >看http method方法就知道针对资源做什么动作 > >看http 状态码就知道动作的结果如何 - `GET` (选择):从服务器上获取一个具体的资源或者一个资源列表。  - `POST` (创建): 在服务器上创建一个新的资源。 - `PUT`(更新):以整体的方式更新服务器上的一个资源。  - `PATCH` (更新):只更新服务器上一个资源的一个属性。 - `DELETE`(删除):删除服务器上的一个资源。  - `HEAD` : 获取一个资源的元数据,如数据的哈希值或最后的更新时间。 - `OPTIONS`:获取客户端能对资源做什么操作的信息。 参考: [RESTful API 设计指南](http://www.ruanyifeng.com/blog/2014/05/restful_api.html) [浅淡RESTful api设计规范](https://www.jianshu.com/p/9bb7e6c683a3 ) [RESTful-API还没理解么?](https://baijiahao.baidu.com/s?id=1646784412070748560&wfr=spider&for=pc) [RESTful api接口安全优雅设计](https://www.jianshu.com/p/9e307a600b44) # OpenAPI >Open API 即开放 API,也称开放平台。 所谓的开放 API(OpenAPI)是服务型网站常见的一种应用,网站的服务商将自己的网站服务封装成一系列 API(Application Programming Interface,应用编程接口)开放出去,供第三方开发者使用,这种行为就叫做开放网站的 API,所开放的 API 就被称作 OpenAPI(开放 API )。 门户形态: https://bitmovin.com/docs/encoding/api-reference/sections/inputs#/Encoding/GetEncodingInputsTypeByInputId https://gitee.com/api/v5/swagger#/getV5ReposOwnerRepoStargazers?ex=no 参考: https://www.jianshu.com/p/5365ef83252a https://xiaoxiami.gitbook.io/swagger/swagger-php-wen-dang/openapi-gui-fan https://www.cnblogs.com/windtail/p/9089383.html https://www.jianshu.com/p/349e130e40d5 [OpenAPI 规范摘要](https://www.jianshu.com/p/5365ef83252a) [OpenAPI的基本结构](https://www.breakyizhan.com/swagger/2810.html) [OpenAPI Specification-github](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md) [OpenAPI Specification-swagger](https://swagger.io/specification/) [basic-structure-swagger](https://swagger.io/docs/specification/basic-structure/) [openapi 3.0 规范说明(git上有中文)](https://blog.csdn.net/qq_36752632/article/details/103565607) [Swagger 2与OpenAPI 3](https://www.jianshu.com/p/879baf1cff07) [OpenAPI2](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) # Swagger [Swagger使用手册](https://www.jianshu.com/p/66a14ea07622) [Swagger-API文档生成框架的基本使用](https://blog.csdn.net/u013985664/article/details/80009274) [swagger2注解详细说明](https://www.cnblogs.com/tangsong41/p/11197782.html) [Swagger2.X注解](https://www.jianshu.com/p/515e48e98152) [Spring Boot 2.x基础教程:Swagger接口分类与各元素排序问题详解](https://baijiahao.baidu.com/s?id=1646880417611836361&wfr=spider&for=pc) [后端 API 接口文档 Swagger 使用指南](https://zhuanlan.zhihu.com/p/98560871) [手把手教你如何玩转Swagger](https://blog.csdn.net/Sophisticated_/article/details/84979834) [在线编辑](http://editor.swagger.io/) [官网文档](https://swagger.io/docs/) [Swagger-强大的API文档工具](https://www.imooc.com/article/71842) [springfox](http://springfox.github.io/springfox/docs/current/) [Annotations](https://github.com/swagger-api/swagger-core/wiki/Annotations) [swagger-codegen](https://github.com/swagger-api/swagger-codegen#getting-started) [data-models](https://swagger.io/docs/specification/data-models/) [swagger注释API详细说明](https://www.cnblogs.com/zhukaixin/p/9324239.html) [schema校验](https://blog.csdn.net/looook/article/details/103094572) swagger-validator https://github.com/cdimascio/express-openapi-validator https://www.cnblogs.com/jiaoyiping/p/4799754.html http://json-schema-validator.herokuapp.com/ https://www.jianshu.com/p/b6310ea2c450 https://www.cnblogs.com/tong-hua/p/12229206.html https://blog.csdn.net/A_finder/article/details/46746559?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight https://swagger.io/docs/ ## 其他 [sdk和open api有什么区别?](https://www.zhihu.com/question/20225153) [SDK、API和OPEN API有啥区别,这是最为形象的比喻](https://cloud.tencent.com/developer/article/1554622) [springBoot整合Swagger接收前端提交的数组、List、对象数据](https://blog.csdn.net/abcchengxuyuan/article/details/89158453?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~first_rank_v2~rank_v25-4-89158453.nonecase&utm_term=swagger%E5%A6%82%E4%BD%95%E6%8E%A5%E5%8F%97list%E6%95%B0%E7%BB%84) [swagger + springboot 传递 List参数解决](https://blog.csdn.net/qq_34173549/article/details/80959719?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~first_rank_v2~rank_v25-3-80959719.nonecase&utm_term=swagger%E5%A6%82%E4%BD%95%E6%8E%A5%E5%8F%97list%E6%95%B0%E7%BB%84) [超详细 Swagger 使用指南](https://blog.csdn.net/Hedon954/article/details/106933323?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.edu_weight&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.edu_weight) 五:使用swagger需要注意的问题 对于只有一个HttpServletRequest参数的方法,如果参数小于5个,推荐使用 @ApiImplicitParams的方式单独封装每一个参数;如果参数大于5个,采用定义一个对象去封装所有参数的属性,然后使用@APiParam的方式 默认的访问地址:ip:port/swagger-ui.html#/,但是在shiro中,会拦截所有的请求,必须加上默认访问路径(比如项目中,就是ip:port/context/swagger-ui.html#/),然后登陆后才可以看到 在GET请求中,参数在Body体里面,不能使用@RequestBody。在POST请求,可以使用@RequestBody和@RequestParam,如果使用@RequestBody,对于参数转化的配置必须统一 controller必须指定请求类型,否则swagger会把所有的类型(6种)都生成出来 swagger在生产环境不能对外暴露,可以使用@Profile({“dev”, “prod”,“pre”})指定可以使用的环境 ## 問題 1.解析swagger的時候,有些paramter字段丟失或者為空? 這是因為解析的時候,有路徑時候/user/{id}這種,路徑需要申明才行(这是{offerId}在路径项中将参数声明为占位符的情况./offers/{offerId},但是在路径级或操作级parameters对象中没有相应的定义。),可以查看parser源碼debug,然後查看到 result類會有相關錯誤提示信息 參考: https://blog.csdn.net/qsx741olm/article/details/97498432 https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#pathsObject https://stackoverflow.com/questions/48189793/swagger-definition-file-validation-in-java https://stackoverflow.com/questions/27155516/swaggerissue-with-path-parameter