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

Duplicated server when generating the openapi file in a custom folder #1204

Closed
GersonTf opened this issue Sep 9, 2023 · 1 comment · Fixed by #1212
Closed

Duplicated server when generating the openapi file in a custom folder #1204

GersonTf opened this issue Sep 9, 2023 · 1 comment · Fixed by #1212

Comments

@GersonTf
Copy link

GersonTf commented Sep 9, 2023

Expected Behavior

doing gradle clean build several times should not duplicate the server.

servers:
- url: http://localhost:8080

Actual Behaviour

the server is duplicated in the generated api.yml doc;

servers:
- url: http://localhost:8080
- url: http://localhost:8080

if you keep doing gradle clean build, it will keep adding a new line.

Steps To Reproduce

  1. I added openapi dependencies
    annotationProcessor("io.micronaut.openapi:micronaut-openapi:5.0.0-M4")
    compileOnly("io.micronaut.openapi:micronaut-openapi:5.0.0-M4")
    implementation("io.swagger.core.v3:swagger-annotations:2.2.15")
  1. the server is added to the Application.groovy:
@Server(url = 'http://localhost:8080')
class Application {
    static void main(String[] args) {
        Micronaut.run(Application, args)
    }
}
  1. create a openapi.properties file and change the target file:
    micronaut.openapi.target.file=./docs/openapi/api.yml
  2. run gradle clean build 2 times or more. The first file will be ok, the second will duplicate the line and so on.

Environment Information

jdk 17.
groovy

Example Application

No response

Version

4.1.0

@GersonTf
Copy link
Author

GersonTf commented Sep 9, 2023

it also happens with @Securityscheme

security:
- bearerAuth: []
- bearerAuth: []

The default behavior works OK, because the generated api doc is inside the gradle build, which is deleted when you do gradle clean, so the file is generated from 0 each time you do gradle clean build and doesn't have duplicated lines. The problem only happens when you change the target file, so the file is not inside the gradle build folder and doesn't get deleted when running gradle clean.

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

Successfully merging a pull request may close this issue.

1 participant