I'm converting a swagger file into an open API v3 one using the openapi-yaml
generator with Maven.
What I would like to do is to put the new file directly into some directory.
However some additional files are generated which I don't need e.g. README.md
, .openapi-generator/VERSION
, .openapi-generator-ignore
Is it possible to disable this behaviour and generate only the .yaml
file?
It still doesn't look possible directly through the openApiGenerate
config. As other suggest it can be done through a script though. As there's no example, here's what I put together by extending the gradle task
openApiGenerate {
generatorName = "java"
inputSpec = (String) "$buildDir/openapi.json"
outputDir = (String) "$rootDir/generated-client"
apiPackage = "com.example.client.api"
modelPackage = "com.example.client.model"
invokerPackage = "com.example.client.invoker"
}
tasks.openApiGenerate {
doLast {
delete (
"$rootDir/generated-client/.openapi-generator",
"$rootDir/generated-client/api",
"$rootDir/generated-client/gradle",
"$rootDir/generated-client/docs"
)
}
}
Yes this is possible using a .openapi-generator-ignore file as documented at:
https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#ignore-file-format
For example, to skip git_push.sh, one can create a file named .openapi-generator-ignore in the root of the output directory with the contents:
# Prevent generator from creating these files:
git_push.sh
Some good documentation can also be found at:
https://openapi-generator.tech/docs/faq-extending/#how-do-i-skip-files-during-code-generation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With