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

Plugin not failing build on connection error #20

Closed tn185070 closed 3 years ago

tn185070 commented 3 years ago

When I added this plugin to my pom I forgot to configure the url so that it would know about the random port the service is starting up on. I expect that this would've caused the build to fail, but I only noticed because I manually looked for the open api file and noticed it was missing.

It would be nice if the plugin would cause the build to fail on connection errors because we are planning on using the output file in our pipeline.

This is a snippet of my log:

19:16:12.353 [main] INFO  [] o.s.b.w.e.netty.NettyWebServer  - Netty started on port[s]: 54826
19:16:22.448 [main] INFO  [] c.n.c.t.api.impl.MainApplication  - Started MainApplication in 30.57 seconds [JVM running for 35.115]
[INFO]
[INFO] --- springdoc-openapi-maven-plugin:1.1:generate (integration-test) @ tokenization-api-impl ---
[ERROR] An error has occured: Response code 403
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.2.RELEASE:stop (post-integration-test) @ tokenization-api-impl ---
[INFO] Stopping application...
19:16:24.128 [RMI TCP Connection(2)-127.0.0.1] INFO  [] o.s.b.a.SpringApplicationAdminMXBeanRegistrar$SpringApplicationAdmin  - Application shutdown requested.

The plugin version is 1.1

ahmedalnuaimi commented 3 years ago

Add this to your plugin configuration:

<configuration>
    <apiDocsUrl>http://localhost:54826/v3/api-docs</apiDocsUrl>
</configuration>

If you changed the context of your WebMVC you would have to add that to the URL too.

tn185070 commented 3 years ago

@bnasslahsen I understand what caused my failure, I was suggesting that this plugin should offer an option to fail the maven build if it can't retrieve the api doc.

bnasslahsen commented 3 years ago

@tn185070,

Please feel free to propose a PR.

Sabotaz commented 1 year ago

@tn185070 How did you managed to pass the random port such as ${local.server.port} to the plugin configuration ?

tn185070 commented 1 year ago

@tn185070 How did you managed to pass the random port such as ${local.server.port} to the plugin configuration ?

I think it was following something like https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/#integration-tests.examples.random-port