zoukankan      html  css  js  c++  java
  • Swagger3 更新配置详解

      

    1.引入依赖,版本3.0.0只引入一个即可

    		<dependency>
    		    <groupId>io.springfox</groupId>
    		    <artifactId>springfox-boot-starter</artifactId>
    		    <version>3.0.0</version>
    		</dependency>

    2. 配置类SwaggerConfig

    package org.fh.config;
    
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    
    import springfox.documentation.builders.ApiInfoBuilder;
    import springfox.documentation.builders.PathSelectors;
    import springfox.documentation.builders.RequestHandlerSelectors;
    import springfox.documentation.oas.annotations.EnableOpenApi;
    import springfox.documentation.service.ApiInfo;
    import springfox.documentation.spi.DocumentationType;
    import springfox.documentation.spring.web.plugins.Docket;
    
    /**
     * 说明:Swagger 接口API生成
     * 作者:FH Admin
     * from fhadmin.org
     */
    @Configuration
    @EnableOpenApi
    public class SwaggerConfig {
    
        @Bean
        public Docket createRestApi() {
            return new Docket(DocumentationType.OAS_30)
                    .apiInfo(apiInfo())
                    .select()
                    .apis(RequestHandlerSelectors.basePackage("org.fh.controller"))	// 为当前包路径
                    .paths(PathSelectors.any())
                    .build();
        }
    
    	private ApiInfo apiInfo() {
    		return new ApiInfoBuilder()
    				.title("FH Admin Swagger3 RESTful API") 	// 页面标题
    				.version("3.0")								// 版本号
    				.description("fhadmin.org")				    // 描述
    				.build();
    	}
    
    }
    

    3.Swagger 拦截配置

    package org.fh.config;
    
    import org.springframework.context.annotation.Configuration;
    import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
    import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
    import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
    
    /**
     * 说明:Swagger 拦截配置
     * 作者:FH Admin
     * from fhadmin.org
     */
    @Configuration
    public class WebMvcConfig implements WebMvcConfigurer {
    
        @Override
        public void addResourceHandlers(ResourceHandlerRegistry registry) {
            registry.
                    addResourceHandler("/swagger-ui/**")
                    .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/")
                    .resourceChain(false);
        }
    
        @Override
        public void addViewControllers(ViewControllerRegistry registry) {
            registry.addViewController("/swagger-ui/")
                    .setViewName("forward:/swagger-ui/index.html");
        }
    }
    
    

    4.访问 127.0.0.1:8081/swagger-ui/index.html

    5.接口说明案例

    处理类上加注解,比如
    @Api("用户注册登录接口")
    
    在方法上加注解,比如
    @ApiOperation(value = "登录", notes="请求登录验证用户接口,校验登录是否成功")
    @ApiImplicitParam(name = "KEYDATA", value = "用户名密码混淆码组合", paramType = "query", required = true, dataType = "String")

    工作流模块-------------------------------www.fhadmin.org

    1.模型管理 :web在线流程设计器、导入导出xml、复制流程、部署流程

    2.流程管理 :导入导出流程资源文件、查看流程图、根据流程实例反射出流程模型、激活挂起

    3.运行中流程:查看流程信息、当前任务节点、当前流程图、作废暂停流程、指派待办人、自由跳转

    4.历史的流程:查看流程信息、流程用时、流程状态、查看任务发起人信息

    5.待办任务 :查看本人个人任务以及本角色下的任务、办理、驳回、作废、指派一下代理人

    6.已办任务 :查看自己办理过的任务以及流程信息、流程图、流程状态(作废 驳回 正常完成)

    办理任务时候可以选择用户进行抄送,就是给被抄送人发送站内信通知当前审批意见以及备注信息

    注:当办理完当前任务时,下一任务待办人会即时通讯收到新任务消息提醒,当作废和完结任务时,

    任务发起人会收到站内信消息通知

  • 相关阅读:
    人工智能背后的故事
    idea 开发插件。
    安卓工作室 Android studio 或 Intellij IDEA 美化 修改 汉化 酷炫 装逼 Android studio or Intellij IDEA beautify modify Chinesization cool decoration
    安卓工作室 android studio文件和代码模板,以及汉化出错问题
    安卓工作室 android studio 汉化后,报错。 设置界面打不开。Can't find resource for bundle java.util.PropertyResourceBundle, key emmet.bem.class.name.element.separator.label
    android studio的汉化 教程 及解析
    安卓工作室Android Studio 快捷键
    安卓工作室 android studio 的 汉化 美化 定制 Android studio's Chinesization beautification customization
    VR开发 VR development
    Lakeshore 中文开发界面,示例项目,飞机大战 等 Lakeshore Chinese development interface, sample project, aircraft war, etc
  • 原文地址:https://www.cnblogs.com/teacher11/p/14902795.html
Copyright © 2011-2022 走看看