Hello,
I am new to Gradle and I am going to create a set of api rest using OpenAPI as Specification and Swagger as Tools for implementing the specification
I have the YAML file available which defines the API REST interfaces and I should generate the code and documentation from it.
I use Gradle version 6, Spring Framework and Spring Boot. I have created three dependent projects among them:
root
| —SubProj1 (API Code generated based on the openAPI specification)
| —SubProj2 (API Code Documentation based on the swagger tool)
| —SubProj3 (Api Business Logic Implementation)
I managed to generate the support code based on the SubProj1 OpenAPI specification using the plugin “org.openapitools: openapi-generator-gradle-plugin: 4.2.2”. Below you can see the draft gradle build
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url “Central Repository:” }
maven { url “https://plugins.gradle.org/m2/” }
maven { url “Central Repository:” }
maven { url “https://oss.sonatype.org/content/repositories/snapshots/” }
}
dependencies {
classpath “org.openapitools:openapi-generator-gradle-plugin:$openApiGeneratorVersion”
}
}
apply plugin: ‘org.openapi.generator’compileJava {
sourceCompatibility= 1.8
targetCompatibility= 1.8
}openApiValidate {
inputSpec = “$rootDir/NM_Rest_API_Definition.yaml”.toString()
}openApiGenerate {
generatorName = “spring”
inputSpec = “$rootDir/NM_Rest_API_Definition.yaml”.toString()
outputDir = “$projectDir/generated-sources/openapi”.toString()
apiPackage = “nm.api”
invokerPackage = “nm.invoker”
modelPackage = “nm.model”
library= “spring-boot”
configOptions = [
dateLibrary: “java8”,
configHelp: “false”
]
systemProperties = [
modelDocs: “true”
]
skipValidateSpec = true
logToStderr = true
generateAliasAsModel = false
enablePostProcessFile = false
}
I made the business logic based on the code generated through the plugin from the previous step in the SubProj3 and I made the war based on.
I can’t, however, generate the code based on the Swagger tool, SubProj2. Is there any plugin? Is there any example of a generation?
Has anyone already found themselves making the doc for the publication of bees on swagger with gradle?