mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
Documentation update (#15728)
* Updated Gradle documentation examples to use correct non-deprecated .set(x) syntax instead of directly assigning * Updated more Gradle documentation examples to use correct non-deprecated .set(x) syntax instead of directly assigning * Updated documentation to use Java 11 instead of Java 8
This commit is contained in:
parent
421bcd1787
commit
f0a624a135
@ -7,7 +7,7 @@ title: Building the code
|
||||
|
||||
To build from source, you need the following installed and available in your `$PATH:`
|
||||
|
||||
* [Java 8](https://java.oracle.com)
|
||||
* [Java 11](https://java.oracle.com)
|
||||
|
||||
* [Apache maven 3.3.4 or greater](https://maven.apache.org/)
|
||||
|
||||
|
@ -34,10 +34,10 @@ _How_ you provide values to options also depends on the tool. OpenAPI Generator
|
||||
|
||||
```
|
||||
openApiGenerate {
|
||||
globalProperties = [
|
||||
globalProperties.set([
|
||||
apis: "",
|
||||
models: "User:Pet"
|
||||
]
|
||||
])
|
||||
}
|
||||
```
|
||||
|
||||
@ -107,12 +107,12 @@ It may seem like a typo but there are two `=` signs in the above example.
|
||||
|
||||
```
|
||||
openApiGenerate {
|
||||
generatorName = "mysql-schema"
|
||||
inputSpec = "$rootDir/spec.yaml".toString()
|
||||
outputDir = "$buildDir/mysql".toString()
|
||||
configOptions = [
|
||||
generatorName.set("mysql-schema")
|
||||
inputSpec.set("$rootDir/spec.yaml")
|
||||
outputDir.set("$buildDir/mysql")
|
||||
configOptions.set([
|
||||
identifierNamingConvention: "snake_case"
|
||||
]
|
||||
])
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -101,29 +101,29 @@ docker run --rm \
|
||||
> **Platform(s)**: Linux, macOS, Windows
|
||||
|
||||
<!-- RELEASE_VERSION -->
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
|
||||
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 11 runtime at a minimum):
|
||||
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.3.0/openapi-generator-cli-6.3.0.jar`
|
||||
JAR location: `https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.6.0/openapi-generator-cli-6.6.0.jar`
|
||||
|
||||
For **Mac/Linux** users:
|
||||
|
||||
```bash
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.3.0/openapi-generator-cli-6.3.0.jar -O openapi-generator-cli.jar
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.6.0/openapi-generator-cli-6.6.0.jar -O openapi-generator-cli.jar
|
||||
```
|
||||
|
||||
For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
|
||||
|
||||
```powershell
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.3.0/openapi-generator-cli-6.3.0.jar
|
||||
Invoke-WebRequest -OutFile openapi-generator-cli.jar https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.6.0/openapi-generator-cli-6.6.0.jar
|
||||
```
|
||||
<!-- /RELEASE_VERSION -->
|
||||
|
||||
After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
|
||||
|
||||
For Mac users, please make sure Java 8 is installed (Tips: run `java -version` to check the version), and export `JAVA_HOME` in order to use the supported Java version:
|
||||
For Mac users, please make sure Java 11 is installed (Tips: run `java -version` to check the version), and export `JAVA_HOME` in order to use the supported Java version:
|
||||
|
||||
```bash
|
||||
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
|
||||
export JAVA_HOME=`/usr/libexec/java_home -v 1.11`
|
||||
export PATH=${JAVA_HOME}/bin:$PATH
|
||||
```
|
||||
|
||||
|
@ -16,7 +16,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
<!-- RELEASE_VERSION -->
|
||||
<version>6.0.0</version>
|
||||
<version>6.6.0</version>
|
||||
<!-- /RELEASE_VERSION -->
|
||||
<executions>
|
||||
<execution>
|
||||
@ -75,10 +75,10 @@ To include in your project, add the following to `build.gradle`:
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url "https://repo1.maven.org/maven2" }
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:5.0.0"
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:6.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ apply plugin: 'org.openapi.generator'
|
||||
This gives access to the following tasks:
|
||||
|
||||
| Task | Description |
|
||||
| ---- | ----------- |
|
||||
|-------------------|---------------------------------------------------------------------------------------------|
|
||||
| openApiGenerate | Generate code via Open API Tools Generator for Open API 2.0 or 3.x specification documents. |
|
||||
| openApiGenerators | Lists generators available via Open API Generators. |
|
||||
| openApiMeta | Generates a new generator to be consumed via Open API Generator. |
|
||||
@ -107,13 +107,13 @@ An example openApiGenerate task configuration for generating a kotlin client:
|
||||
|
||||
```groovy
|
||||
openApiGenerate {
|
||||
generatorName = "kotlin"
|
||||
inputSpec = "$rootDir/specs/petstore-v3.0.yaml".toString()
|
||||
outputDir = "$buildDir/generated".toString()
|
||||
apiPackage = "org.openapi.example.api"
|
||||
invokerPackage = "org.openapi.example.invoker"
|
||||
modelPackage = "org.openapi.example.model"
|
||||
configOptions.putAll([
|
||||
generatorName.set("kotlin")
|
||||
inputSpec.set("$rootDir/specs/petstore-v3.0.yaml")
|
||||
outputDir.set("$buildDir/generated")
|
||||
apiPackage.set("org.openapi.example.api")
|
||||
invokerPackage.set("org.openapi.example.invoker")
|
||||
modelPackage.set("org.openapi.example.model")
|
||||
configOptions.set([
|
||||
dateLibrary: "java8"
|
||||
])
|
||||
}
|
||||
|
@ -44,17 +44,17 @@ All extensions can be rewritten as tasks. Where you can have only a single exten
|
||||
----
|
||||
// Validating a single specification
|
||||
openApiValidate {
|
||||
inputSpec = "$rootDir/petstore-v3.0-invalid.yaml".toString()
|
||||
inputSpec.set("$rootDir/petstore-v3.0-invalid.yaml")
|
||||
}
|
||||
|
||||
// Define a task for validating one specification
|
||||
task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.ValidateTask) {
|
||||
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
|
||||
inputSpec.set("$rootDir/petstore-v3.0.yaml")
|
||||
}
|
||||
|
||||
// Define a task for validating another specification
|
||||
task validateBadSpec(type: org.openapitools.generator.gradle.plugin.tasks.ValidateTask) {
|
||||
inputSpec = "$rootDir/petstore-v3.0-invalid.yaml".toString()
|
||||
inputSpec.set("$rootDir/petstore-v3.0-invalid.yaml")
|
||||
}
|
||||
|
||||
// Define a task for batch validations
|
||||
@ -85,7 +85,7 @@ task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.Valid
|
||||
outputs.upToDateWhen { false }
|
||||
outputs.cacheIf { false }
|
||||
|
||||
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
|
||||
inputSpec.set("$rootDir/petstore-v3.0.yaml")
|
||||
}
|
||||
----
|
||||
====
|
||||
@ -97,7 +97,7 @@ task validateGoodSpec(type: org.openapitools.generator.gradle.plugin.tasks.Valid
|
||||
[source,group]
|
||||
----
|
||||
plugins {
|
||||
id "org.openapi.generator" version "6.3.0"
|
||||
id "org.openapi.generator" version "6.6.0"
|
||||
}
|
||||
----
|
||||
|
||||
@ -108,12 +108,12 @@ Using https://docs.gradle.org/current/userguide/plugins.html#sec:old_plugin_appl
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url "https://repo1.maven.org/maven2" }
|
||||
mavenCentral()
|
||||
// or, via Gradle Plugin Portal:
|
||||
// url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:6.3.0"
|
||||
classpath "org.openapitools:openapi-generator-gradle-plugin:6.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -435,10 +435,10 @@ When configuring `globalProperties` in order to perform selective generation you
|
||||
----
|
||||
openApiGenerate {
|
||||
// other settings omitted
|
||||
globalProperties = [
|
||||
globalProperties.set([
|
||||
modelDocs: "false",
|
||||
apis: "false"
|
||||
]
|
||||
])
|
||||
}
|
||||
----
|
||||
When enabling generation of only specific parts you either have to provide CSV list of what you particularly are generating or provide an empty string `""` to generate everything. If you provide `"true"` it will be treated as a specific name of model or api you want to generate.
|
||||
@ -446,10 +446,10 @@ When enabling generation of only specific parts you either have to provide CSV l
|
||||
----
|
||||
openApiGenerate {
|
||||
// other settings omitted
|
||||
globalProperties = [
|
||||
globalProperties.set([
|
||||
apis: "",
|
||||
models: "User:Pet"
|
||||
]
|
||||
])
|
||||
}
|
||||
----
|
||||
====
|
||||
@ -518,15 +518,15 @@ This task exposes all options available via OpenAPI Generator CLI and the OpenAP
|
||||
[source,groovy]
|
||||
----
|
||||
openApiGenerate {
|
||||
generatorName = "kotlin"
|
||||
inputSpec = "$rootDir/specs/petstore-v3.0.yaml".toString()
|
||||
outputDir = "$buildDir/generated".toString()
|
||||
apiPackage = "org.openapi.example.api"
|
||||
invokerPackage = "org.openapi.example.invoker"
|
||||
modelPackage = "org.openapi.example.model"
|
||||
configOptions = [
|
||||
generatorName.set("kotlin")
|
||||
inputSpec.set("$rootDir/specs/petstore-v3.0.yaml")
|
||||
outputDir.set("$buildDir/generated")
|
||||
apiPackage.set("org.openapi.example.api")
|
||||
invokerPackage.set("org.openapi.example.invoker")
|
||||
modelPackage.set("org.openapi.example.model")
|
||||
configOptions.set([
|
||||
dateLibrary: "java8"
|
||||
]
|
||||
])
|
||||
}
|
||||
----
|
||||
|
||||
@ -579,8 +579,8 @@ Please run the above task to list all available generators.
|
||||
[source,groovy]
|
||||
----
|
||||
openApiMeta {
|
||||
generatorName = "Jim"
|
||||
packageName = "us.jimschubert.example"
|
||||
generatorName.set("Jim")
|
||||
packageName.set("us.jimschubert.example")
|
||||
}
|
||||
----
|
||||
|
||||
@ -610,8 +610,8 @@ BUILD SUCCESSFUL in 0s
|
||||
[source,groovy]
|
||||
----
|
||||
openApiValidate {
|
||||
inputSpec = "/src/openapi-generator/modules/openapi-generator/src/test/resources/3_0/petstore.yaml"
|
||||
recommend = true
|
||||
inputSpec.set("/src/openapi-generator/modules/openapi-generator/src/test/resources/3_0/petstore.yaml")
|
||||
recommend.set(true)
|
||||
}
|
||||
----
|
||||
|
||||
@ -670,29 +670,29 @@ You can define any number of generator tasks; the generated code does _not_ need
|
||||
|
||||
```gradle
|
||||
task buildGoClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
|
||||
generatorName = "go"
|
||||
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
|
||||
additionalProperties = [
|
||||
generatorName.set("go")
|
||||
inputSpec.set("$rootDir/petstore-v3.0.yaml")
|
||||
additionalProperties.set([
|
||||
packageName: "petstore"
|
||||
]
|
||||
outputDir = "$buildDir/go".toString()
|
||||
configOptions = [
|
||||
])
|
||||
outputDir.set("$buildDir/go")
|
||||
configOptions.set([
|
||||
dateLibrary: "threetenp"
|
||||
]
|
||||
])
|
||||
}
|
||||
task buildKotlinClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
|
||||
generatorName = "kotlin"
|
||||
inputSpec = "$rootDir/petstore-v3.0.yaml".toString()
|
||||
outputDir = "$buildDir/kotlin".toString()
|
||||
apiPackage = "org.openapitools.example.api"
|
||||
invokerPackage = "org.openapitools.example.invoker"
|
||||
modelPackage = "org.openapitools.example.model"
|
||||
configOptions = [
|
||||
generatorName.set("kotlin")
|
||||
inputSpec.set("$rootDir/petstore-v3.0.yaml")
|
||||
outputDir.set("$buildDir/kotlin")
|
||||
apiPackage.set("org.openapitools.example.api")
|
||||
invokerPackage.set("org.openapitools.example.invoker")
|
||||
modelPackage.set("org.openapitools.example.model")
|
||||
configOptions.set([
|
||||
dateLibrary: "java8"
|
||||
]
|
||||
globalProperties = [
|
||||
])
|
||||
globalProperties.set([
|
||||
modelDocs: "false"
|
||||
]
|
||||
])
|
||||
}
|
||||
```
|
||||
|
||||
@ -740,7 +740,7 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath('org.openapitools:openapi-generator-gradle-plugin:6.3.0') {
|
||||
classpath('org.openapitools:openapi-generator-gradle-plugin:6.6.0') {
|
||||
exclude group: 'com.google.guava'
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user