openapi-tools / swagger-maven-plugin

Maven plugin to activate the Swagger Core library to generate OpenAPI documentation.
MIT License
72 stars 46 forks source link

Any plans for adding support for Spring MVC applications? #37

Open Cejkis-zz opened 5 years ago

Cejkis-zz commented 5 years ago

Hey, I was wondering if support for Spring apps is on the table, like it is supported in the case of original plugin by Kongchen. Thanks a lot! @strohel

langecode commented 5 years ago

Hi,

This comes up once in a while. The framework was designed specifically to be a thing wrapper around the JAX-RS support already present in Swagger. We experienced some problems with the Kongchen plugin because it re-implemented logic from Swagger.

However as this seems to be something many are interested in maybe we should investigate whether a framework exists for the Spring annotations which could be utilized to generate OpenAPI specification from Sping REST annotations.

ahoehma commented 4 years ago

I migrated one of my project from swagger-2 to openapi-3 and I was forced to add

   <dependency>
      <groupId>jakarta.ws.rs</groupId>
      <artifactId>jakarta.ws.rs-api</artifactId>
    </dependency>

Version 2.1.6 (comes with springboot 2.2.6.RELEASE)

And so I can add the rs-annotations to my "normal" spring-mvc-methods :)

So now I'm able to have a open-api-ui (which seems to parse the mvc-annotations)

    <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-ui</artifactId>
    </dependency>

and I can use the maven plugin to generate my api.yml :)

ahoehma commented 4 years ago

Hi all ... it would be a good idea to add some "support" to be able to ignore Spring's special "ResponseEntity" ... currently I'm using this type everywhere in my RestController and the generated open-api is reflecting this type. Would be nice to "skip" this and instead of using the "real" return-type .... as far as I remember ... https://github.com/kongchen/swagger-maven-plugin ... support this.

piotrpolak commented 4 years ago

https://github.com/kongchen/swagger-maven-plugin has a couple of bugs such as not being able to specify example POST body. I am also hoping the official plugin will support Spring MVC.

farnots commented 1 year ago

I migrated one of my project from swagger-2 to openapi-3 and I was forced to add

   <dependency>
      <groupId>jakarta.ws.rs</groupId>
      <artifactId>jakarta.ws.rs-api</artifactId>
    </dependency>

Version 2.1.6 (comes with springboot 2.2.6.RELEASE)

And so I can add the rs-annotations to my "normal" spring-mvc-methods :)

So now I'm able to have a open-api-ui (which seems to parse the mvc-annotations)

   <dependency>
     <groupId>org.springdoc</groupId>
     <artifactId>springdoc-openapi-ui</artifactId>
   </dependency>

and I can use the maven plugin to generate my api.yml :)

Hello @ahoehma, I'm trying to use the plugin to generated open-api docs from my spring mvc controllers. I try your solution but no endpoint is found. Any info on that ?