Comments (6)
@jangalinski @Clemzd @int128 and others that find this issue, here's an example:
plugins {
// ...
id("org.hidetake.swagger.generator") version "2.18.1"
}
// ...
dependencies {
swaggerCodegen("io.swagger.codegen.v3:swagger-codegen-cli:3.0.8")
// ... other Swagger dependencies like annotations
}
// ...
swaggerSources {
// Gradle recommends `register` over `create` to avoid eagerly creating/configuring items.
register("petstore") {
// Part of the "petstore" SwaggerSource
// Need to save a reference of it here because the `this` scope changes below.
val validationTask = validation
setInputFile(file("petstore-swagger.json"))
// The method signiature is `code(@DelegatesTo(GenerateSwaggerCode) Closure closure)`
// So best to use `delegateClosureOf<GenerateSwaggerCode>`
// https://docs.gradle.org/current/userguide/kotlin_dsl.html#groovy_closures_from_kotlin
code(delegateClosureOf<GenerateSwaggerCode> {
language = "spring"
components = listOf("models")
dependsOn(validationTask)
})
}
}
tasks.named("compileJava").configure {
dependsOn(tasks.named("generateSwaggerCode"))
}
sourceSets {
val main by getting
val petstore by swaggerSources.getting
main.java.srcDir("${petstore.code.outputDir}/src/main/java")
}
from gradle-swagger-generator-plugin.
I have it working on version 2.15.0 and gradle 5 with this
swaggerSources {
create( "qwerservice", {
setInputFile( file("swagger.yml") )
code.outputDir = file( "$buildDir/client" )
code.language = "spring"
code.additionalProperties = mapOf( "group-id" to "com.qwer",
"dateLibrary" to "java8",
"java8" to "true",
"modelPackage" to "com.qwer.model",
"apiPackage" to "com.qwer.api",
"invokerPackage" to "com.qwer.invoker" )
} )
}
from gradle-swagger-generator-plugin.
alternatively you can create a custom task like this:
import org.hidetake.gradle.swagger.generator.GenerateSwaggerCode
plugins {
id("org.hidetake.swagger.generator") version "2.18.2"
}
dependencies {
swaggerCodegen("io.swagger.codegen.v3:swagger-codegen-cli:3.0.23")
}
tasks {
register<GenerateSwaggerCode>("petstore") {
inputFile = projectDir.resolve("petstore.yaml")
language = "spring"
}
}
from gradle-swagger-generator-plugin.
It is not supported yet. It will be supported in the future release.
from gradle-swagger-generator-plugin.
@mywill hi! Could you share your build.gradle.kts? I am trying to make it work with kotlindsl too.
from gradle-swagger-generator-plugin.
fyi to anyone seeing this, that "this scope changes" thing is not necessary. kotlin lets you use this@register and such, to access different scopes that are injected into the closure. it allows similar with return@ for breaking out of closures
from gradle-swagger-generator-plugin.
Related Issues (20)
- A Release hasn't been made since Feb 2020. Missing OAS3 verification which is in master HOT 1
- Android Studio 2020.3.1 (latest stable) requires Gradle 7 + tweaks to plugin HOT 1
- Dependency Dashboard
- Action Required: Fix Renovate Configuration
- The latest release no longer supports Java 11 HOT 3
- JAVA 8 support for the plugin HOT 3
- False usage of gradle cache on new code generator version HOT 1
- No duplicate handling strategy has been set for task resolveSwaggerTemplate HOT 2
- Plugin generates new files despite the inputFiles are not changed since the last generation
- Can't generate SwaggerUI with plugin version 2.19.2 HOT 2
- New versions are not compatible with gradle 6.x
- Problem generating Java code with schema property "oneOf"
- Move to latest Gradle API and best practices HOT 5
- Response for Controller with type of "Map of Map" is not properly generated.
- oneOf Polymorphism Broken
- Using `resttemplate` and `useBeanValidation` does not include `validation-api` HOT 1
- Support jakarta imports HOT 1
- Question: Please could you indicate how to generate the client code? HOT 1
- Configuration cache HOT 3
- Specifying skipFormModel global property does not work
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 gradle-swagger-generator-plugin.