Skip to content

Instantly share code, notes, and snippets.

@tslmy
Created September 16, 2022 18:59
Show Gist options
  • Save tslmy/ad85e44047af1f1b995db1aed7f2ded1 to your computer and use it in GitHub Desktop.
Save tslmy/ad85e44047af1f1b995db1aed7f2ded1 to your computer and use it in GitHub Desktop.
Generate code from OpenAPI contracts: Gradle
plugins {
id 'org.hidetake.swagger.generator' version '2.19.2'
}
dependencies {
// https://github.com/int128/gradle-swagger-generator-plugin#code-generation
swaggerCodegen 'io.swagger.codegen.v3:swagger-codegen-cli:3.0.35'
}
swaggerSources {
// We name this API "petstore".
petstore {
inputFile = file('openapi-contract.yaml')
code {
language = 'java'
configFile = file('swagger-config.json')
outputDir = file('build/gen-src')
components = [
// Whether each of the following should be generated.
apis: false,
apiTests: false,
models: true,
modelTests: false,
]
additionalProperties = [
'includeSwaggerAnnotations': false,
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment