简体   繁体   English

春季3和春季4的Swagger版本

[英]Swagger Version for Spring 3 and Spring 4

I want to documenting a REST API with Swagger and Spring MVC, 我想用Swagger和Spring MVC记录REST API,

And I find out that Spring 3 only can use Swagger V1 而且我发现Spring 3只能使用Swagger V1

        <artifactId>swagger-springmvc</artifactId>
        <version>1.0.2</version>

when I add @ApiParam in front of @RequestBody , do not display completely in Data Type. 当我在@RequestBody前面添加@ApiParam时,不要完全在数据类型中显示。

Finally I choose Swagger V2 in Spring 4 最后,我在Spring 4中选择Swagger V2

I add some dependency and change, as below . 我添加了一些依赖项和更改,如下所示。

        <artifactId>springfox-swagger2</artifactId>
        <version>2.2.2</version>
        <artifactId>spring-web</artifactId>
        <artifactId>4.1.6.RELEASE</artifactId>

Now can display any API info when I needs, 现在可以在需要时显示任何API信息,

  1. But still no idea why Spring 3 only can use SwaggerV1 但是仍然不知道为什么Spring 3只能使用SwaggerV1

  2. and the difference between the Spring 3 & 4 when use Swagger V2 和使用Swagger V2时Spring 3和4之间的区别

  3. why Spring 3 not need spring-web ,but Spring 4 need 为什么Spring 3不需要spring-web,但是Spring 4需要

If need any information , please tell me 如果需要任何信息,请告诉我

I will be grateful for any help you can provide. 感谢您提供的任何帮助。

DISCLAIMER: SpringFox is not a product and is an OSS project. 免责声明:SpringFox不是产品,而是OSS项目。 Im one of the maintainers of the project and currently the only active maintainer. 我是该项目的维护者之一,目前是唯一的活跃维护者。

Having said that, let me answer some of your questions. 话虽如此,让我回答您的一些问题。

But still no idea why Spring 3 only can use SwaggerV1 但是仍然不知道为什么Spring 3只能使用SwaggerV1

As a policy, the current actively maintained version is one minor version behind the latest version of spring. 作为一项策略,当前主动维护的版本比spring的最新版本低一个次要版本。 Swagger v1 is quite old, so when swagger 2 was released we actively moved to a newer version of spring and the last version that supports spring 3 is 1.0.2 . Swagger v1已经很老了,因此在发布Swagger 2时,我们积极地迁移到spring的较新版本,而支持spring 3的最新版本是1.0.2 This follows the same guidelines that spring projects like spring-hateoas follow. 这遵循与春季项目一样的指导原则,如spring-hateoas

and the difference between the Spring 3 & 4 when use Swagger V2 和使用Swagger V2时Spring 3和4之间的区别

The difference is that spring 3 is not really a supported version for springfox v2.x. 区别在于spring 3实际上不是springfox v2.x的受支持版本。 The officially tested version of spring is 4.1.7.RELEASE for v2.2.2 . spring的官方测试版本是4.1.7.RELEASEv2.2.2

why Spring 3 not need spring-web ,but Spring 4 need 为什么Spring 3不需要spring-web,但是Spring 4需要

This is because we spring is a provided dependency of springfox. 这是因为我们spring是springfox provided dependency项。 So library consumers of can provide any version > 4.1 and the library would just work. 因此,的库使用者可以提供任何版本> 4.1的库,库就可以正常工作。 This was not the case in spring 3 because we shipped the springfox library with the spring dependencies. 在Spring 3中不是这种情况,因为我们附带了带有Spring依赖项的springfox库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM