使用父项目(微服务机箱)中的SwaggerUI配置

我正在创建项目,它是一种微服务机箱。我正在尝试添加SwaggerUI支持,但是遇到了一些问题。我想在机箱项目中配置Swagger,并在子项目中使用该配置。另外,我还要记录来自机箱和子项目的所有REST端点。

机箱(父项目)的基本配置(Swagger2Config.class)

@Bean
public Docket api() {
    return new Docket(DocumentationType.SWAGGER_2)
            .select()
            .paths(PathSelectors.any())
            .build()
            .tags(new Tag("",""));
            // Also with some additional info
}

REST端点示例(父项目)

@GetMapping("/example")
public String getExample() {
     return "Example";
}

机箱项目中的pom.xml(Swagger配置只是模块之一)

<parent>
    <artifactId>spring-example-chassis</artifactId>
    <groupId>com.example.microservice</groupId>
    <version>0.0.1-snAPSHOT</version>
</parent>

<artifactId>rest</artifactId>
<version>0.0.1-snAPSHOT</version>
<packaging>pom</packaging>

子项目对父项目的pom.xml依赖项

<dependency>
   <groupId>com.example.microservice</groupId>
   <artifactId>rest</artifactId>
   <version>0.0.1-snAPSHOT</version>
   <type>pom</type>
</dependency>

子项目的示例REST端点

@GetMapping("/child")
public String getExample() {
     return "ChildExample";
}

子项目的main()函数

@SpringBootApplication
public class Main {
    public static void main(String[] args) {
        SpringApplication.run(Main.class,args);
    }
}

我尝试使用@ EnableSwagger2注释Main类,但是它创建了默认配置,并且仅显示/ child端点。我尝试使用@Import(Swagger2Configuration.class),但它也无法正常工作,但是我不得不再尝试几次。

您知道是否可以通过父子项目创建带有所有端点的SwaggerUI页面的方法吗?有什么方法可以将自定义值从子项目传递到父配置,例如文档版本,自定义标签或Swagger使用的任何信息?

预先感谢

hopehappy502 回答:使用父项目(微服务机箱)中的SwaggerUI配置

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3157878.html

大家都在问