当前位置: 首页 > news >正文

台州网站搭建seo在线优化排名

台州网站搭建,seo在线优化排名,建站登录,设计一个网站重点是什么前言 spring项目中可以使用springfox或者springdoc#xff0c;通过写注解的方式生成swagger文档#xff0c;下面介绍一种不写注解#xff0c;动态生成swagger文档的方式#xff0c;在某些场景会适用#xff0c;例如接口是动态生成的#xff0c;此时swagger就不能通过注解…前言 spring项目中可以使用springfox或者springdoc通过写注解的方式生成swagger文档下面介绍一种不写注解动态生成swagger文档的方式在某些场景会适用例如接口是动态生成的此时swagger就不能通过注解来生成了。 一、定义swagger模板 通过观察一个swagger文档的openapi结构将其中需要动态替换的部分写成变量生成freemaker的ftl模板。 通过点击swagger图示链接可以查看openapi的json结构。 修改一个json结构生成一个ftl模板,将模板放在springboot项目的resources/static/data-service-swagger-templates下面 {openapi: 3.0.3,info: {title: 通用查询-[${interfaceName}]接口,description: 通用查询接口,version: 0.0.1},servers: [{url: ${dataServicePrefix},description: Generated server url}],security: [{secretHeader: []}],paths: {${url}: {post: {tags: [数据服务-通用查询接口],summary: 通用查询接口,description: 通用查询接口请求体采用统一数据结构,operationId: getData2UsingPOST,requestBody: {content: {application/json: {schema: {$ref: #/components/schemas/DmoRequest}}}},responses: {200: {description: OK,content: {*/*: {schema: {$ref: #/components/schemas/ResponseEntity}}}},201: {description: Created},401: {description: Unauthorized},403: {description: Forbidden},404: {description: Not Found}}}}},components: {schemas: {ResponseEntity: {title: ResponseEntity,type: object,properties: {desc: {type: string,description: 错误详细描述},message: {type: string,description: 如果为非200的返回可以将此message提示给用户},requestURL: {type: string},stackTrace: {type: string,description: 后端的异常栈信息如果过长只截取前面一部分},status: {type: integer,description: 200正常401未登陆403没有权限400请求参数校验失败500服务器内部错误,format: int32},tookInMillis: {type: integer,description: 请求耗时,format: int64},value: {type: object}}},DmoRequest: {title: DmoRequest,type: object,properties: {fulltextNode: {$ref: #/components/schemas/QueryNode},node: {$ref: #/components/schemas/QueryNode},pageNumber: {type: integer,description: 页码,format: int32},pageSize: {type: integer,description: 每页条数,format: int32},showColumns: {uniqueItems: true,type: array,items: {type: string,description: 显示的列}},sorts: {type: array,items: {$ref: #/components/schemas/DmoSort}}}},QueryNode: {title: QueryNode,type: object,description: 查询条件,properties: {children: {type: array,items: {$ref: #/components/schemas/QueryNode}},data: {$ref: #/components/schemas/NodeData},type: {type: string,description: 节点类型,enum: [AND, LEAF, OR, ROOT]}}},NodeData: {title: NodeData,type: object,description: 节点数据,properties: {operator: {type: string,description: 操作符,enum: [BETWEEN, EQ, EXISTS, GE, GT, IN, IS_NOT_NULL, IS_NULL, LE, LIKE, LT, NE, NOT_BETWEEN, NOT_EXISTS, NOT_IN, NOT_LIKE, PREFIX, REGEXP]},param: {type: string,description: 参数名称一般对应表的列名},value: {type: array,description: 参数值,items: {type: object}}}},DmoSort: {title: DmoSort,type: object,description: 排序,properties: {column: {type: string,description: 列名},sortOrder: {type: string,description: 排序方式,enum: [ASC, DESC]}}}},securitySchemes: {secretHeader: {type: apiKey,name: Authorization,in: header}}} }二、使用freemarker生成openapi的JSON结构 1.引入库 代码如下示例 dependencygroupIdorg.freemarker/groupIdartifactIdfreemarker/artifactIdversion2.3.32/version /dependency 2.生成json 下面的serviceInterface就是一个实体可以自行定义 ApiOperation(value 获取openapi的JSON, notes 获取openapi的JSON)GetMapping(/swagger-json/{id})public String getSwaggerJson(ApiParam(value id) PathVariable Integer id) throws BaseException {ServiceInterface serviceInterface getServiceInterface(id);return getOpenApiJson(ServiceInterface serviceInterface, test.ftl) ;}private String getOpenApiJson(ServiceInterface serviceInterface, String ftl) throws BaseException {freemarker.template.Configuration configuration new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_0);// 设置默认编码configuration.setDefaultEncoding(utf-8);//设置类加载器configuration.setClassLoaderForTemplateLoading(this.getClass().getClassLoader(), data-service-swagger-templates);try {// 生成模板对象Template template configuration.getTemplate(fileName);TEMPLATE_CACHE.put(fileName, template);} catch (Exception e) {throw new BaseException(String.format(获取模版文件:[%s]出错, fileName), e);}Template template getFltTemplate(ftl);String dataServicePrefix dataServiceProtocol dataServiceUpstream;MapString, String dataMap new HashMap();dataMap.put(interfaceName, serviceInterface.getServiceName());dataMap.put(dataServicePrefix, dataServicePrefix);dataMap.put(url, serviceInterface.getUrl());StringWriter sw new StringWriter();try {template.process(dataMap, sw);return sw.toString();} catch (Exception e) {throw new BaseException(模板转换出错: e.getMessage(), e);}}三、前端生成swagger示例 !DOCTYPE html htmlheadtitle数据服务接口文档/titlelink relstylesheet typetext/css hrefswagger-ui.css//headbodydiv idswagger-ui/divscript srcswagger-ui-bundle.js/scriptscriptwindow.onload function () {SwaggerUIBundle({// url: http://localhost:14500/v3/api-docs, // 替换成您的OpenAPI规范的URL或文件路径// url: swagger-custom-select.json, // 替换成您的OpenAPI规范的URL或文件路径url: http://192.168.33.22:3282/dmo/service-interface/swagger-json/226, // 替换成您的OpenAPI规范的URL或文件路径dom_id: #swagger-ui,deepLinking: true,});};/script/body /html 其中url 为第二步的接口 用到的css和js下载地址https://blog.csdn.net/weixin_41085315/article/details/124965953 四、测试
http://www.yutouwan.com/news/305612/

相关文章:

  • 个人网站流程响应式网站怎么做才实用
  • 建立网站的软件下载wordpress文章代码插件
  • 吉林手机版建站系统开发网站 设计理念
  • 长春做网站设计装潢设计与工艺教育专业
  • 丹徒网站2013电子商务网站建设
  • 和平县做网站手机网站欣赏
  • 协会网站信息平台建设梧州论坛看点
  • 网站建设的基本需求有哪些方面建设机械网站制作
  • 网站后台尺寸一般做多大的免费承接网站建设
  • 雅安建设网站浦口区建设中学网站
  • 绿色大气漂亮dedecms茶叶企业网站进行网站建设
  • 网站建设中的需求报告功能wordpress七牛云加速
  • 湖南网站设计制作网站关键词怎么优化排名
  • 哪个网站是营销型网站汽车网有哪些网站大全
  • 客户网站建设洽谈方案谷歌seo查询
  • 昆明 网站建设兼职网站建设与管理是哪个软件
  • 上海模板建站公司应届生在淮北招的网站建设类型岗位
  • 深圳 SEO 网站建设 哪里学大连网站开发培训
  • 新公司需要做网站wordpress前端文章编辑器
  • 网站建设栏目说明百度一下首页登录
  • 江西专业的网站建设公司免费建设公司网站
  • 百度网盘网站开发文档模板怎么做网站填内容
  • 租空间做网站需要多少钱wordpress 获取评论id
  • 招商加盟网站模板程序企业宣传片视频制作公司
  • 移动互联网网站开发技术深圳建设外贸网站
  • 影视网站搭建平台南昌县城乡规划建设局官方网站
  • 自己建网站怎么推广网站建设阶段要做什么
  • 什么软件可以优化关键词对网站外部的搜索引擎优化
  • 咸阳网站建设培训学校wordpress主题white
  • 淮北网站建设费用wordpress如何看访问量