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

Fails to generate openapi.json spec #40

Closed 54754N4 closed 2 years ago

54754N4 commented 2 years ago

I tried running ./mvnw springdoc-openapi:generate and also ./mvn verify but i get a weird ConnectException somehow:

[ERROR] An error has occured
java.net.ConnectException: Connection refused: connect
    at sun.nio.ch.Net.connect0 (Native Method)
    at sun.nio.ch.Net.connect (Net.java:579)
    at sun.nio.ch.Net.connect (Net.java:568)
    at sun.nio.ch.NioSocketImpl.connect (NioSocketImpl.java:588)
    at java.net.Socket.connect (Socket.java:633)
    at java.net.Socket.connect (Socket.java:583)
    at sun.net.NetworkClient.doConnect (NetworkClient.java:183)
    at sun.net.www.http.HttpClient.openServer (HttpClient.java:498)
    at sun.net.www.http.HttpClient.openServer (HttpClient.java:603)
    at sun.net.www.http.HttpClient.<init> (HttpClient.java:246)
    at sun.net.www.http.HttpClient.New (HttpClient.java:351)
    at sun.net.www.http.HttpClient.New (HttpClient.java:373)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient (HttpURLConnection.java:1309)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0 (HttpURLConnection.java:1242)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect (HttpURLConnection.java:1128)
    at sun.net.www.protocol.http.HttpURLConnection.connect (HttpURLConnection.java:1057)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0 (HttpURLConnection.java:1665)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream (HttpURLConnection.java:1589)
    at java.net.HttpURLConnection.getResponseCode (HttpURLConnection.java:529)
    at org.springdoc.maven.plugin.SpringDocMojo.execute (SpringDocMojo.java:110)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:301)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:165)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:157)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:121)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:127)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:47)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:156)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:72)

My pom file plugin is:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <jvmArguments>-Dspring.application.admin.enabled=true -Pintegration -Dspringdoc.writer-with-default-pretty-printer=true</jvmArguments>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>start</goal>
                <goal>stop</goal>
            </goals>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-maven-plugin</artifactId>
    <version>1.4</version>
    <executions>
        <execution>
            <id>integration-test</id>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
</plugin>

And i'm using springdoc-openapi-ui:1.6.9. Am i doing something wrong ?

bnasslahsen commented 2 years ago

@54754N4,

Just review your local configuration ...

MrAlucardDante commented 1 year ago

@54754N4 Did you manage to find what was causing the issue ? I am experiencing it too.

@bnasslahsen What do you mean by

Just review your local configuration ...

This is not really helping

bnasslahsen commented 1 year ago

It means we can do nothing for it as well. It's local configuration issue - not reproducible in our end!

MrAlucardDante commented 1 year ago

So I managed to get rid of the error by changing the management port to another port and configuring springdoc to use the management port, like it is mentionned in the documentation, although I'd like to use the same port, but I can live with that.

But now I get a 401 because I am using Spring Security to secure the actuator endpoints and my API.

I tried disabling Spring security with http.authorizeHttpRequests().anyRequest().permitAll(); but now I get a 404.

Any ideas ?