gradle-swagger-generator-plugin icon indicating copy to clipboard operation
gradle-swagger-generator-plugin copied to clipboard

Support url for inputFile

Open rverma-nikiai opened this issue 6 years ago • 1 comments
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.

rverma-nikiai avatar Apr 03 '19 12:04 rverma-nikiai

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

LangInteger avatar Sep 02 '20 07:09 LangInteger