Giambi Huang
Giambi Huang

Reputation: 121

Swagger Version for Spring 3 and Spring 4

I want to documenting a REST API with Swagger and Spring MVC,

And I find out that Spring 3 only can use 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.

Finally I choose Swagger V2 in Spring 4

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,

  1. But still no idea why Spring 3 only can use SwaggerV1

  2. and the difference between the Spring 3 & 4 when use Swagger V2

  3. why Spring 3 not need spring-web ,but Spring 4 need

If need any information , please tell me

I will be grateful for any help you can provide.

Upvotes: 1

Views: 5858

Answers (1)

Dilip Krishnan
Dilip Krishnan

Reputation: 5487

DISCLAIMER: SpringFox is not a product and is an OSS project. 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

As a policy, the current actively maintained version is one minor version behind the latest version of 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. This follows the same guidelines that spring projects like spring-hateoas follow.

and the difference between the Spring 3 & 4 when use Swagger V2

The difference is that spring 3 is not really a supported version for springfox v2.x. The officially tested version of spring is 4.1.7.RELEASE for v2.2.2.

why Spring 3 not need spring-web ,but Spring 4 need

This is because we spring is a provided dependency of springfox. So library consumers of can provide any version > 4.1 and the library would just work. This was not the case in spring 3 because we shipped the springfox library with the spring dependencies.

Upvotes: 3

Related Questions