springdoc / springdoc-openapi-maven-plugin

Library for OpenAPI 3 with spring-boot
https://springdoc.org
Apache License 2.0
141 stars 37 forks source link

Hello World #17

Closed philsturgeon closed 3 years ago

philsturgeon commented 3 years ago

Hey there, I am not a Java or Spring Boot developer but I'm trying to truck my way through all this to get a hello world running for an article, and.... weeeell thing's aren't off to a great start. Hoping somebody here can help.

I've got cloned down https://github.com/springdoc/springdoc-openapi-demos and I'm in springdoc-openapi-spring-boot-2-webmvc. I can run the site with mvn spring-boot:run and if I go to http://localhost:8080 then I see good old Swagger UI running in the browser.

Now, I'd like to be able to run an export command, which will take all the annotations and pump out the YAML, which this plugin should be able to do, but for some reason it's talking about integration-tests and I don't have any of those, as its just a demo application.

Is there a way I can just run a command?

For example, the PHP equivilent is swagger-php, and for that you just run the following:

vendor/bin/openapi -o openapi.json

This means I can enable all sorts of workflows, CI, deployments, etc without needing to wrap ot all up with tests somehow. Could there be a custom maven command I run? Or could it be part of mvn site or something?

For context I'm getting an error when I run mvn integration-test.

2020-09-29 10:06:52.627  INFO 95573 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-09-29 10:06:52.636  INFO 95573 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-09-29 10:06:52.636  INFO 95573 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.38]
2020-09-29 10:06:52.738  INFO 95573 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-09-29 10:06:52.738  INFO 95573 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1416 ms
2020-09-29 10:06:53.121  INFO 95573 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-09-29 10:06:53.761  INFO 95573 --- [  restartedMain] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2020-09-29 10:06:53.842  INFO 95573 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2020-09-29 10:06:53.886  INFO 95573 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-09-29 10:06:53.916  INFO 95573 --- [  restartedMain] org.springdoc.demo.app2.Application      : Started Application in 3.157 seconds (JVM running for 3.959)
2020-09-29 10:07:21.363  INFO 95573 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  34.347 s
[INFO] Finished at: 2020-09-29T10:07:21+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.0.RELEASE:start (pre-integration-test) on project springdoc-openapi-spring-boot-2-webmvc: Could not figure out if the application has started: Failed to connect to MBean server at port 9001: Could not invoke shutdown operation: Spring application did not start before the configured timeout (30000ms -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
bnasslahsen commented 3 years ago

@philsturgeon,

You can see here, sample configuration of the maven plugin for the sample you have mentioned: https://github.com/springdoc/springdoc-openapi-demos/commit/3f6c97729f73f445ad4f0f306a7ea1aed57daa48

philsturgeon commented 3 years ago

Thank you!