Comments (15)
The huge question is: Must the application be app and running on port 8080 prior to running the command above?
from springdoc-openapi-maven-plugin.
Here is the significant part of pom.xml:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>${start-class}</mainClass>
<fork>true</fork>
<jvmArguments>-Dspring.application.admin.enabled=true</jvmArguments>
<!--
Enable the line below to have remote debugging of your application on port 5005
<jvmArguments>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</jvmArguments>
-->
</configuration>
</plugin>
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<apiDocsUrl>http://localhost:8080/v3/api-docs</apiDocsUrl>
<outputFileName>openapi.json</outputFileName>
<outputDir>${project.basedir}/target/docs/asciidoc</outputDir>
</configuration>
</plugin>
I merged the existing spring-boot-maven-plugin settings with the one provided in your docs.
from springdoc-openapi-maven-plugin.
I made it work by removing:
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
and running the app on 8080, priror to running maven mvn -Pprod,war clean verify -DskipTests=true
command.
from springdoc-openapi-maven-plugin.
You are missing this in your project, is Kotlin code but I guess you will understand the idea
@Configuration
class SecurityConfig() : WebSecurityConfigurerAdapter() {
@Throws(Exception::class)
override fun configure(http: HttpSecurity) {
http
.csrf().disable()
.antMatcher("/**")
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.NEVER)
.and()
.authorizeRequests()
.antMatchers("/v3/api-docs").permitAll()
.anyRequest().denyAll()
.and()
.httpBasic()
}
}
from springdoc-openapi-maven-plugin.
You are missing this in your project, is Kotlin code but I guess you will understand the idea
@Configuration class SecurityConfig() : WebSecurityConfigurerAdapter() { @Throws(Exception::class) override fun configure(http: HttpSecurity) { http .csrf().disable() .antMatcher("/**") .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.NEVER) .and() .authorizeRequests() .antMatchers("/v3/api-docs").permitAll() .anyRequest().denyAll() .and() .httpBasic() } }
could you elaborate a little, I cant translate it to my Java project
from springdoc-openapi-maven-plugin.
So, your problem is that you are not allowing access to the route where the swagger is exposed.
You need to create a configuration class and extend from WebSecurityConfigurerAdapter
and override the method configure(HttpSecurity http){....}
and allow the access to "/v3/api-docs"
path
from springdoc-openapi-maven-plugin.
If we run the spring context from a war deployment(No main class), How to solve java.net.ConnectException: Connection refused (Connection refused)?
from springdoc-openapi-maven-plugin.
The solution will be the same. You just need to find out how to expose the route "/v3/api-docs"
for a war
deployment, and I will assume is quite similar
from springdoc-openapi-maven-plugin.
Hi @randyhbh
I've already to add route "/v3/api-docs"
both of WebSecurityConfigurerAdapter class and yaml file. but it still has Connection Refuse. This is my pom.
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>true</skip>
<jvmArguments>-Dspring.application.admin.enabled=true</jvmArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDir>${project.build.directory}/springdoc</outputDir>
</configuration>
</plugin>
</plugins>
from springdoc-openapi-maven-plugin.
I have the exact same problem. Adding permission to the security configuration didn't solve the problem.
Btw, why is this issue closed?
from springdoc-openapi-maven-plugin.
@micobarac Could you share your project or a newly created one that reproduce the issue so I can take a look and see if I can help you?
from springdoc-openapi-maven-plugin.
I have almost the same configuration as @randyhbh .
When I run
mvn -Pprod,war clean verify -DskipTests=true
I get:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.7.RELEASE:start (pre-integration-test) on project openprovider-cdb: Could not figure out if the application has started: Failed to connect to MBean server at port 9001: Could not invoke shutdown operation: Connection refused to host: 127.0.0.1; nested exception is:
[ERROR] java.net.ConnectException: Connection refused (Connection refused)
[ERROR] -> [Help 1]
[ERROR]
from springdoc-openapi-maven-plugin.
Had the same problem - the issue was in the custom path, which was setup in application.yml.
from springdoc-openapi-maven-plugin.
The huge question is: Must the application be app and running on port 8080 prior to running the command above?
This plugin only works if the app server is running before it can make the output file. In spring boot, we run tests before even building the artifact. How can I just generate the file without having to run the app server?
So I just read through your source code and you're scraping the URL to parse the json and then saving it to a file. This will not work for my automation needs where the file needs to be created at build, not deploy. The phase of Integration test is misleading.
URL urlForGetRequest = new URL(apiDocsUrl);
from springdoc-openapi-maven-plugin.
No way for that
from springdoc-openapi-maven-plugin.
Related Issues (20)
- Fails to generate openapi.json spec HOT 4
- Springdoc-openapi-maven-plugin without springboot HOT 1
- Auto JSON format openapi.json HOT 5
- html output HOT 1
- Created Openapi.json file changes each time HOT 1
- There is no way to generate multiple open api files in one plugin config HOT 1
- The outputFileName property should not start with "/"
- Runtime or buildtime? HOT 1
- Plugin do not generate java.util.Date correctly HOT 1
- Plugin does not generate responses correctly HOT 1
- Plugin does not generate list of objects correctly HOT 1
- Actual build-time capability without a running server HOT 3
- Plugin does not generate specification HOT 1
- Are there locations configuration? HOT 1
- Generate api document by Maven plugin during compilation HOT 1
- Add "failOnError" option HOT 1
- Error while working with context-path HOT 2
- Add ability to set title for openapi specification HOT 1
- Setting all imports with full path HOT 1
- Will the plugin generate multiple files if GroupedOpenAPI is used? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from springdoc-openapi-maven-plugin.