gradle-swagger-generator-plugin
gradle-swagger-generator-plugin copied to clipboard
Support url for inputFile
trafficstars
Describe the feature
swagger-codegen-cli allows to pass an url for input file specifications and can generate over that. Swagger maven codegen plugin supports the same so as open api plugin.
Why do you want the feature?
This will bring feature parity and is very useful in generating client directly from public definition urls.
Before this feature is done, some work arounds are available to match this requirement
task downloadSomething(type: MyDownload) {
sourceUrl = 'http://20.20.20.66:32601/v2/api-docs?group=Default'
target = new File('petstore.yaml')
}
generateSwaggerCode.dependsOn downloadSomething
class MyDownload extends DefaultTask {
@Input
String sourceUrl
@OutputFile
File target
@TaskAction
void download() {
ant.get(src: sourceUrl, dest: target)
}
}
swaggerSources {
petstore {
inputFile = file('petstore.yaml')
code {
language = 'spring'
}
}
}
Reference: https://stackoverflow.com/questions/17123606/how-to-download-external-files-in-gradle