kongchen / swagger-maven-plugin

JAX-RS & SpringMVC supported maven build plugin, helps you generate Swagger JSON and API document in build phase.
http://kongchen.github.io/swagger-maven-plugin/
Apache License 2.0
761 stars 450 forks source link

Try to generate document.html and json with maven plugin and spring boot 1.3.0.M5 #226

Open fabMrc opened 9 years ago

fabMrc commented 9 years ago

I try without any success to generate static files from swagger maven plugin.

            <plugin>
                <groupId>com.github.kongchen</groupId>
                <artifactId>swagger-maven-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <apiSources>
                        <apiSource>
                            <springmvc>true</springmvc>
                            <locations>com.web.controler</locations>
                            <schemes>http</schemes>
                            <host>localhost:8080</host>
                            <basePath>/</basePath>
                            <info>
                                <title>Swagger sample</title>
                                <version>v2</version>
                                <description>
                                    This is the Rest API Documentation 
                                </description>
                                <contact>
                                    <email>toto@mail.com</email>
                                    <name>toto</name>
                                </contact>
                            </info>
                            <templatePath>${basedir}/src/test/resources/strapdown.html.hbs</templatePath>
                            <outputPath>${basedir}/generated/document.html</outputPath>
                            <swaggerDirectory>${basedir}/generated/swagger-ui</swaggerDirectory>
                        </apiSource>
                    </apiSources>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    <dependencies>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-core</artifactId>
            <version>1.5.3</version>
        </dependency>

Document.html and json are generated but without any API detected

I have my rest controller annotated like bellow

/**
 * Handles requests for rest call.
 */
@Api(value = "/")
@RestController
public class RestController {

    @ApiOperation(value = "Load pet parent tree", notes = "notes", response = Pet .class)
    @RequestMapping(value = "/rest/tree/pet", method = RequestMethod.GET)
    public Pet loadParentsTree(
            @ApiParam(required = true, value = "petId") @PathVariable String petId
            HttpServletResponse response) {
mrvijaytiwari commented 8 years ago

+1

khipis commented 8 years ago

I also have the same problem, json is generated but without any API detected

I've also tryed adding

<swaggerApiReader>com.github.kongchen.swagger.docgen.reader.SpringMvcApiReader</swaggerApiReader>

but it's also not working.

Anyone can help? :) :+1:

khipis commented 8 years ago

Ok finally I get the working example. @fabMrc and @mrvijaytiwari please check simple sample of working plugin with Spring MVC annotations on this fork:

https://github.com/khipis/swagger-maven-example

:cookie:

sdcuike commented 7 years ago

+1

fabMrc commented 7 years ago

Nice I am waiting to use it without swagger specific annotation (only spring mvc) is it possible ?

PAX523 commented 7 years ago

If you use Spring Boot you have to make sure that your @RequestMapping uses the value attribute instead of path. Otherwise, no API is detected.

See: #467