Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot generate swagger docs (SpringBoot Project) #864

Open
fraballi opened this issue Jul 9, 2021 · 1 comment
Open

Cannot generate swagger docs (SpringBoot Project) #864

fraballi opened this issue Jul 9, 2021 · 1 comment

Comments

@fraballi
Copy link

fraballi commented Jul 9, 2021

Hi, great plugin, whereas one can generate swagger.json without exposing urls!

Does my endpoint requires spring-like annotations such as: RestController or Controller?
Or can declare a @Component and the plugin will index @Api like annotations?

pom.xml

        <plugin>
                <groupId>com.github.kongchen</groupId>
                <artifactId>swagger-maven-plugin</artifactId>
                <version>1.8</version>
                <configuration>
                    <apiSources>
                        <apiSource>
                            <springmvc>true</springmvc>
                            <locations>
                                <location>com.fraballi.endpoint.MyEndpoint</location>
                            </locations>
                            <info>
                                <title>Endpoint Test</title>
                                <version>1.0</version>
                            </info>
                            <swaggerFileName>my-swagger</swaggerFileName>
                            <outputPath>${project.build.directory}/swagger/swagger.html</outputPath>
                            <swaggerDirectory>${project.build.directory}/swagger</swaggerDirectory>
                            <attachSwaggerArtifact>true</attachSwaggerArtifact>
                        </apiSource>
                    </apiSources>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
      </plugin>

My endpoint:

@Component
@SvcServerEndpoint(id = "myEndpoint", basePath = "/decrypt")
public class MyEndpoint {
 ...

   @ApiOperation(value = "A message", notes = "Returns a message")
   @ApiResponses(value = { @ApiResponse(code = HttpStatus.SC_OK, message = "A message", response = MyResponse.class) })
   @ResponseBody
   @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
   public DeferredResult<ResponseEntity<?>> post(
         @ApiParam(name = "request", type = "MyRequest", required = true) @RequestBody final MyRequest request,
         final HttpServletRequest servletRequest) {

         ...
   }

Got this message:

[INFO] Reflections took 80 ms to scan 261 urls, producing 2 keys and 2 values 

Failed to execute goal com.github.kongchen:swagger-maven-plugin:3.1.8:generate (default) on project swagger-test-project: null
@michaelwangwangwang
Copy link

below 3.1.7 maybe work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants