diff --git a/.github/workflows/gradle-test.yaml b/.github/workflows/gradle-test.yaml
index e2c3fa24ec37..8202bcd8bbc6 100644
--- a/.github/workflows/gradle-test.yaml
+++ b/.github/workflows/gradle-test.yaml
@@ -28,6 +28,8 @@ jobs:
- samples/client/petstore/java/jersey2-java8
- samples/client/petstore/java/okhttp-gson
- samples/client/petstore/java/okhttp-gson-group-parameter
+ - samples/client/petstore/java/okhttp
+ - samples/client/petstore/java/okhttp-group-parameter
- samples/client/petstore/java/webclient-swagger2
- samples/client/petstore/java/native
- samples/client/petstore/java/native-jakarta
diff --git a/.github/workflows/samples-java-client-echo-api-jdk8.yaml b/.github/workflows/samples-java-client-echo-api-jdk8.yaml
index 9785fe5c2630..17f6b9449d4b 100644
--- a/.github/workflows/samples-java-client-echo-api-jdk8.yaml
+++ b/.github/workflows/samples-java-client-echo-api-jdk8.yaml
@@ -6,6 +6,7 @@ on:
- samples/client/echo_api/java/apache-httpclient/**
- samples/client/echo_api/java/feign-gson/**
- samples/client/echo_api/java/okhttp-gson/**
+ - samples/client/echo_api/java/okhttp/**
- samples/client/echo_api/java/resttemplate/**
- samples/client/echo_api/java/resteasy/**
pull_request:
@@ -13,6 +14,7 @@ on:
- samples/client/echo_api/java/apache-httpclient/**
- samples/client/echo_api/java/feign-gson/**
- samples/client/echo_api/java/okhttp-gson/**
+ - samples/client/echo_api/java/okhttp/**
- samples/client/echo_api/java/resteasy/**
jobs:
build:
@@ -26,6 +28,7 @@ jobs:
- samples/client/echo_api/java/apache-httpclient
- samples/client/echo_api/java/feign-gson
- samples/client/echo_api/java/okhttp-gson
+ - samples/client/echo_api/java/okhttp
- samples/client/echo_api/java/resttemplate
- samples/client/echo_api/java/resteasy
steps:
diff --git a/.github/workflows/samples-java-client-jdk11.yaml b/.github/workflows/samples-java-client-jdk11.yaml
index 59981610ccd2..2d3decb138bf 100644
--- a/.github/workflows/samples-java-client-jdk11.yaml
+++ b/.github/workflows/samples-java-client-jdk11.yaml
@@ -13,12 +13,19 @@ on:
- samples/openapi3/client/petstore/java/native**
- samples/client/others/java/okhttp-gson-oneOf/**
- samples/client/others/java/okhttp-gson-oneOf-array/**
+ - samples/client/others/java/okhttp-oneOf/**
+ - samples/client/others/java/okhttp-oneOf-array/**
+ - samples/client/others/java/okhttp-jackson-oneOf/**
+ - samples/client/others/java/okhttp-jackson3-oneOf/**
+ - samples/client/others/java/okhttp-jsonb-oneOf/**
- samples/client/others/java/resttemplate-useAbstractionForFiles/**
- samples/client/others/java/webclient-useAbstractionForFiles/**
- samples/client/petstore/java/webclient-useSingleRequestParameter/**
- samples/client/others/java/jersey2-oneOf-duplicates/**
- samples/client/others/java/jersey2-oneOf-Mixed/**
- samples/client/others/java/okhttp-gson-streaming/**
+ - samples/client/others/java/okhttp-streaming/**
+ - samples/client/echo_api/java/okhttp**
- samples/client/others/java/resteasy/**
- samples/client/others/java/apache-httpclient/**
- samples/client/others/java/resttemplate-list-schema-validation/**
@@ -35,12 +42,19 @@ on:
- samples/openapi3/client/petstore/java/native**
- samples/client/others/java/okhttp-gson-oneOf/**
- samples/client/others/java/okhttp-gson-oneOf-array/**
+ - samples/client/others/java/okhttp-oneOf/**
+ - samples/client/others/java/okhttp-oneOf-array/**
+ - samples/client/others/java/okhttp-jackson-oneOf/**
+ - samples/client/others/java/okhttp-jackson3-oneOf/**
+ - samples/client/others/java/okhttp-jsonb-oneOf/**
- samples/client/others/java/resttemplate-useAbstractionForFiles/**
- samples/client/others/java/webclient-useAbstractionForFiles/**
- samples/client/petstore/java/webclient-useSingleRequestParameter/**
- samples/client/others/java/jersey2-oneOf-duplicates/**
- samples/client/others/java/jersey2-oneOf-Mixed/**
- samples/client/others/java/okhttp-gson-streaming/**
+ - samples/client/others/java/okhttp-streaming/**
+ - samples/client/echo_api/java/okhttp**
- samples/client/others/java/resteasy/**
- samples/client/others/java/apache-httpclient/**
- samples/client/others/java/resttemplate-list-schema-validation/**
@@ -93,24 +107,47 @@ jobs:
- samples/client/petstore/java/feign-hc5
- samples/client/petstore/java/feign-no-nullable
- samples/client/petstore/java/okhttp-gson-awsv4signature
+ - samples/client/petstore/java/okhttp-awsv4signature
- samples/openapi3/client/petstore/java/jersey2-java8-special-characters
- samples/openapi3/client/petstore/java/native
- samples/client/petstore/java/okhttp-gson-swagger1/
+ - samples/client/petstore/java/okhttp-swagger1/
- samples/client/petstore/java/resttemplate-swagger1/
- samples/openapi3/client/petstore/java/jersey2-java8-swagger1/
- samples/client/petstore/java/okhttp-gson-swagger2/
+ - samples/client/petstore/java/okhttp-swagger2/
- samples/client/petstore/java/resttemplate-swagger2/
- samples/openapi3/client/petstore/java/jersey2-java8-swagger2/
- samples/client/others/java/okhttp-gson-oneOf/
- samples/client/others/java/okhttp-gson-oneOf-array/
+ - samples/client/others/java/okhttp-oneOf/
+ - samples/client/others/java/okhttp-oneOf-array/
+ - samples/client/others/java/okhttp-jackson-oneOf/
+ - samples/client/others/java/okhttp-jackson3-oneOf/
+ - samples/client/others/java/okhttp-jsonb-oneOf/
- samples/client/echo_api/java/okhttp-gson-user-defined-templates/
+ - samples/client/echo_api/java/okhttp-user-defined-templates/
+ - samples/client/echo_api/java/okhttp-jackson-user-defined-templates/
- samples/client/others/java/resttemplate-useAbstractionForFiles/
- samples/client/others/java/webclient-useAbstractionForFiles/
- samples/client/others/java/jersey2-oneOf-duplicates/
- samples/client/others/java/jersey2-oneOf-Mixed/
- samples/client/others/java/resttemplate-list-schema-validation/
- samples/client/petstore/java/okhttp-gson-3.1-duplicated-operationid/
+ - samples/client/petstore/java/okhttp-3.1-duplicated-operationid/
- samples/client/others/java/okhttp-gson-streaming/
+ - samples/client/others/java/okhttp-streaming/
+ - samples/client/petstore/java/okhttp-jackson/
+ - samples/client/petstore/java/okhttp-jackson3/
+ - samples/client/petstore/java/okhttp-jsonb/
+ - samples/client/petstore/java/okhttp-jackson-jspecify/
+ - samples/client/petstore/java/okhttp-jackson3-jspecify/
+ - samples/client/petstore/java/okhttp-jsonb-jspecify/
+ - samples/client/petstore/java/okhttp-nullable-required/
+ - samples/client/petstore/java/okhttp-jackson-nullable-required/
+ - samples/client/petstore/java/okhttp-jsonb-nullable-required/
+ - samples/client/petstore/java/okhttp-group-parameter/
+ - samples/client/petstore/java/okhttp-parcelableModel/
- samples/client/petstore/java/resteasy/
- samples/client/petstore/java/apache-httpclient/
steps:
diff --git a/.github/workflows/samples-java-petsore-client-jdk11.yaml b/.github/workflows/samples-java-petsore-client-jdk11.yaml
index 3a7ae2b89e77..d23c44ccbf4a 100644
--- a/.github/workflows/samples-java-petsore-client-jdk11.yaml
+++ b/.github/workflows/samples-java-petsore-client-jdk11.yaml
@@ -9,6 +9,9 @@ on:
- samples/client/petstore/java/okhttp-gson/**
- samples/client/petstore/java/okhttp-gson-3.1/**
- samples/client/petstore/java/okhttp-gson-dynamicOperations/**
+ - samples/client/petstore/java/okhttp/**
+ - samples/client/petstore/java/okhttp-3.1/**
+ - samples/client/petstore/java/okhttp-dynamicOperations/**
- samples/client/petstore/java-micronaut-client/**
pull_request:
paths:
@@ -17,6 +20,9 @@ on:
- samples/client/petstore/java/okhttp-gson/**
- samples/client/petstore/java/okhttp-gson-3.1/**
- samples/client/petstore/java/okhttp-gson-dynamicOperations/**
+ - samples/client/petstore/java/okhttp/**
+ - samples/client/petstore/java/okhttp-3.1/**
+ - samples/client/petstore/java/okhttp-dynamicOperations/**
- samples/client/petstore/java-micronaut-client/**
jobs:
build:
@@ -31,6 +37,9 @@ jobs:
- samples/client/petstore/java/okhttp-gson
- samples/client/petstore/java/okhttp-gson-3.1
- samples/client/petstore/java/okhttp-gson-dynamicOperations
+ - samples/client/petstore/java/okhttp
+ - samples/client/petstore/java/okhttp-3.1
+ - samples/client/petstore/java/okhttp-dynamicOperations
- samples/client/petstore/java-micronaut-client
services:
petstore-api:
diff --git a/.github/workflows/samples-java-sbt.yaml b/.github/workflows/samples-java-sbt.yaml
index f12fdbdabc7c..07050ded404d 100644
--- a/.github/workflows/samples-java-sbt.yaml
+++ b/.github/workflows/samples-java-sbt.yaml
@@ -4,9 +4,11 @@ on:
push:
paths:
- 'samples/client/petstore/java/okhttp-gson/**'
+ - 'samples/client/petstore/java/okhttp/**'
pull_request:
paths:
- 'samples/client/petstore/java/okhttp-gson/**'
+ - 'samples/client/petstore/java/okhttp/**'
jobs:
build:
name: Build sbt/Java client, servers
@@ -17,6 +19,7 @@ jobs:
sample:
# clients
- samples/client/petstore/java/okhttp-gson
+ - samples/client/petstore/java/okhttp
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v5.7.0
diff --git a/bin/configs/java-okhttp-3.1-duplicated-operationid.yaml b/bin/configs/java-okhttp-3.1-duplicated-operationid.yaml
new file mode 100644
index 000000000000..ed9a40b9ab99
--- /dev/null
+++ b/bin/configs/java-okhttp-3.1-duplicated-operationid.yaml
@@ -0,0 +1,13 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-3.1-duplicated-operationid
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_1/java/duplicated_operationid.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+validateSpec: false
+additionalProperties:
+ serializationLibrary: gson
+ artifactId: petstore-okhttp-31-do
+ hideGenerationTimestamp: "true"
+ disallowAdditionalPropertiesIfNotPresent: false
+openapiNormalizer:
+ FIX_DUPLICATED_OPERATIONID: true
diff --git a/bin/configs/java-okhttp-3.1.yaml b/bin/configs/java-okhttp-3.1.yaml
new file mode 100644
index 000000000000..f861ce844e7e
--- /dev/null
+++ b/bin/configs/java-okhttp-3.1.yaml
@@ -0,0 +1,21 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-3.1
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+validateSpec: false
+nameMappings:
+ _type: underscoreType
+ type_: typeWithUnderscore
+parameterNameMappings:
+ _type: underscoreType
+ type_: typeWithUnderscore
+additionalProperties:
+ serializationLibrary: gson
+ artifactId: petstore-okhttp-31
+ hideGenerationTimestamp: "true"
+ useOneOfDiscriminatorLookup: "true"
+ disallowAdditionalPropertiesIfNotPresent: false
+ enumPropertyNaming: legacy
+openapiNormalizer:
+ FIX_DUPLICATED_OPERATIONID: true
diff --git a/bin/configs/java-okhttp-awsv4signature.yaml b/bin/configs/java-okhttp-awsv4signature.yaml
new file mode 100644
index 000000000000..f41000fa2cbe
--- /dev/null
+++ b/bin/configs/java-okhttp-awsv4signature.yaml
@@ -0,0 +1,12 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-awsv4signature
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: gson
+ artifactId: okhttp-awsv4signature
+ hideGenerationTimestamp: "true"
+ useOneOfDiscriminatorLookup: "true"
+ disallowAdditionalPropertiesIfNotPresent: false
+ withAWSV4Signature: true
diff --git a/bin/configs/java-okhttp-dynamicOperations.yaml b/bin/configs/java-okhttp-dynamicOperations.yaml
new file mode 100644
index 000000000000..6662ce08e14d
--- /dev/null
+++ b/bin/configs/java-okhttp-dynamicOperations.yaml
@@ -0,0 +1,10 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-dynamicOperations
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: gson
+ artifactId: petstore-okhttp-dynamicoperations
+ hideGenerationTimestamp: "true"
+ dynamicOperations: "true"
diff --git a/bin/configs/java-okhttp-echo-api.yaml b/bin/configs/java-okhttp-echo-api.yaml
new file mode 100644
index 000000000000..9d9a2dd21adc
--- /dev/null
+++ b/bin/configs/java-okhttp-echo-api.yaml
@@ -0,0 +1,9 @@
+generatorName: java
+outputDir: samples/client/echo_api/java/okhttp
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: gson
+ artifactId: echo-api-okhttp
+ hideGenerationTimestamp: "true"
diff --git a/bin/configs/java-okhttp-group-parameter.yaml b/bin/configs/java-okhttp-group-parameter.yaml
new file mode 100644
index 000000000000..d0fbac5b7666
--- /dev/null
+++ b/bin/configs/java-okhttp-group-parameter.yaml
@@ -0,0 +1,11 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-group-parameter
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-group-parameter.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: gson
+ artifactId: petstore-okhttp-group-parameter
+ hideGenerationTimestamp: "true"
+ disallowAdditionalPropertiesIfNotPresent: false
+ useSingleRequestParameter: true
diff --git a/bin/configs/java-okhttp-gson-user-defined-templates.yaml b/bin/configs/java-okhttp-gson-user-defined-templates.yaml
new file mode 100644
index 000000000000..650c2dc1b195
--- /dev/null
+++ b/bin/configs/java-okhttp-gson-user-defined-templates.yaml
@@ -0,0 +1,17 @@
+generatorName: java
+outputDir: samples/client/echo_api/java/okhttp-gson-user-defined-templates
+library: okhttp-gson
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ hideGenerationTimestamp: "true"
+files:
+ README.mustache:
+ destinationFilename: info.md
+ api_doc.mustache:
+ templateType: APIDocs
+ destinationFilename: Documentation.md
+ pojo.mustache:
+ templateType: Model
+ folder: modelCopy
+ destinationFilename: .java
diff --git a/bin/configs/java-okhttp-jackson-jspecify.yaml b/bin/configs/java-okhttp-jackson-jspecify.yaml
new file mode 100644
index 000000000000..aa8a86e4490e
--- /dev/null
+++ b/bin/configs/java-okhttp-jackson-jspecify.yaml
@@ -0,0 +1,17 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-jackson-jspecify
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/java/jspecify.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+validateSpec: false
+additionalProperties:
+ serializationLibrary: jackson
+ artifactId: petstore-okhttp-jackson-jspecify
+ hideGenerationTimestamp: "true"
+ generateBuilders: true
+ useReflectionEqualsHashCode: "true"
+ openApiNullable: "false"
+ useJspecify: true
+typeMappings:
+ OffsetDateTime: java.time.Instant
+ BigDecimal: java.math.BigDecimal
diff --git a/bin/configs/java-okhttp-jackson-nullable-required.yaml b/bin/configs/java-okhttp-jackson-nullable-required.yaml
new file mode 100644
index 000000000000..3b3908d08d8e
--- /dev/null
+++ b/bin/configs/java-okhttp-jackson-nullable-required.yaml
@@ -0,0 +1,11 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-jackson-nullable-required
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-nullable-required.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: jackson
+ artifactId: nullable-required-okhttp-jackson
+ hideGenerationTimestamp: "true"
+ useOneOfDiscriminatorLookup: "true"
+ disallowAdditionalPropertiesIfNotPresent: false
diff --git a/bin/configs/java-okhttp-jackson-oneOf.yaml b/bin/configs/java-okhttp-jackson-oneOf.yaml
new file mode 100644
index 000000000000..36d18dede918
--- /dev/null
+++ b/bin/configs/java-okhttp-jackson-oneOf.yaml
@@ -0,0 +1,9 @@
+generatorName: java
+outputDir: samples/client/others/java/okhttp-jackson-oneOf
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_twoPrimitives.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ artifactId: okhttp-jackson-oneOf
+ hideGenerationTimestamp: "true"
+ serializationLibrary: jackson
diff --git a/bin/configs/java-okhttp-jackson-user-defined-templates.yaml b/bin/configs/java-okhttp-jackson-user-defined-templates.yaml
new file mode 100644
index 000000000000..51266292cac4
--- /dev/null
+++ b/bin/configs/java-okhttp-jackson-user-defined-templates.yaml
@@ -0,0 +1,19 @@
+generatorName: java
+outputDir: samples/client/echo_api/java/okhttp-jackson-user-defined-templates
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ artifactId: echo-api-okhttp-jackson-user-defined-templates
+ hideGenerationTimestamp: "true"
+ serializationLibrary: jackson
+files:
+ README.mustache:
+ destinationFilename: info.md
+ api_doc.mustache:
+ templateType: APIDocs
+ destinationFilename: Documentation.md
+ pojo.mustache:
+ templateType: Model
+ folder: modelCopy
+ destinationFilename: .java
diff --git a/bin/configs/java-okhttp-jackson.yaml b/bin/configs/java-okhttp-jackson.yaml
new file mode 100644
index 000000000000..05db7e932de7
--- /dev/null
+++ b/bin/configs/java-okhttp-jackson.yaml
@@ -0,0 +1,12 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-jackson
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/java/native/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: jackson
+ artifactId: petstore-okhttp-jackson2
+ hideGenerationTimestamp: "true"
+ generateBuilders: true
+ useReflectionEqualsHashCode: "true"
+ openApiNullable: "false"
diff --git a/bin/configs/java-okhttp-jackson3-jspecify.yaml b/bin/configs/java-okhttp-jackson3-jspecify.yaml
new file mode 100644
index 000000000000..56c265ee314f
--- /dev/null
+++ b/bin/configs/java-okhttp-jackson3-jspecify.yaml
@@ -0,0 +1,18 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-jackson3-jspecify
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/java/jspecify.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+validateSpec: false
+additionalProperties:
+ serializationLibrary: jackson
+ artifactId: petstore-okhttp-jackson3-jspecify
+ hideGenerationTimestamp: "true"
+ generateBuilders: true
+ useReflectionEqualsHashCode: "true"
+ useJackson3: "true"
+ openApiNullable: "false"
+ useJspecify: true
+typeMappings:
+ OffsetDateTime: java.time.Instant
+ BigDecimal: java.math.BigDecimal
diff --git a/bin/configs/java-okhttp-jackson3-oneOf.yaml b/bin/configs/java-okhttp-jackson3-oneOf.yaml
new file mode 100644
index 000000000000..78f41c6e5682
--- /dev/null
+++ b/bin/configs/java-okhttp-jackson3-oneOf.yaml
@@ -0,0 +1,10 @@
+generatorName: java
+outputDir: samples/client/others/java/okhttp-jackson3-oneOf
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_twoPrimitives.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ artifactId: okhttp-jackson3-oneOf
+ hideGenerationTimestamp: "true"
+ serializationLibrary: jackson
+ useJackson3: true
diff --git a/bin/configs/java-okhttp-jackson3.yaml b/bin/configs/java-okhttp-jackson3.yaml
new file mode 100644
index 000000000000..1837fa1c9195
--- /dev/null
+++ b/bin/configs/java-okhttp-jackson3.yaml
@@ -0,0 +1,13 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-jackson3
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/java/native/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: jackson
+ artifactId: petstore-okhttp-jackson3
+ hideGenerationTimestamp: "true"
+ generateBuilders: true
+ useReflectionEqualsHashCode: "true"
+ useJackson3: "true"
+ openApiNullable: "false"
diff --git a/bin/configs/java-okhttp-jsonb-jspecify.yaml b/bin/configs/java-okhttp-jsonb-jspecify.yaml
new file mode 100644
index 000000000000..8da0158866fc
--- /dev/null
+++ b/bin/configs/java-okhttp-jsonb-jspecify.yaml
@@ -0,0 +1,16 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-jsonb-jspecify
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/java/jspecify.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+validateSpec: false
+additionalProperties:
+ serializationLibrary: jsonb
+ artifactId: petstore-okhttp-jsonb-jspecify
+ hideGenerationTimestamp: "true"
+ generateBuilders: true
+ useReflectionEqualsHashCode: "true"
+ useJspecify: true
+typeMappings:
+ OffsetDateTime: java.time.Instant
+ BigDecimal: java.math.BigDecimal
diff --git a/bin/configs/java-okhttp-jsonb-nullable-required.yaml b/bin/configs/java-okhttp-jsonb-nullable-required.yaml
new file mode 100644
index 000000000000..931d5a216524
--- /dev/null
+++ b/bin/configs/java-okhttp-jsonb-nullable-required.yaml
@@ -0,0 +1,11 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-jsonb-nullable-required
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-nullable-required.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: jsonb
+ artifactId: nullable-required-okhttp-jsonb
+ hideGenerationTimestamp: "true"
+ useOneOfDiscriminatorLookup: "true"
+ disallowAdditionalPropertiesIfNotPresent: false
diff --git a/bin/configs/java-okhttp-jsonb-oneOf.yaml b/bin/configs/java-okhttp-jsonb-oneOf.yaml
new file mode 100644
index 000000000000..f5a575096f0c
--- /dev/null
+++ b/bin/configs/java-okhttp-jsonb-oneOf.yaml
@@ -0,0 +1,9 @@
+generatorName: java
+outputDir: samples/client/others/java/okhttp-jsonb-oneOf
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_twoPrimitives.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ artifactId: okhttp-jsonb-oneOf
+ hideGenerationTimestamp: "true"
+ serializationLibrary: jsonb
diff --git a/bin/configs/java-okhttp-jsonb.yaml b/bin/configs/java-okhttp-jsonb.yaml
new file mode 100644
index 000000000000..c5e6aba06e70
--- /dev/null
+++ b/bin/configs/java-okhttp-jsonb.yaml
@@ -0,0 +1,11 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-jsonb
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/java/native/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: jsonb
+ artifactId: petstore-okhttp-jsonb
+ hideGenerationTimestamp: "true"
+ generateBuilders: true
+ useReflectionEqualsHashCode: "true"
diff --git a/bin/configs/java-okhttp-nullable-required.yaml b/bin/configs/java-okhttp-nullable-required.yaml
new file mode 100644
index 000000000000..9dc6a3a31159
--- /dev/null
+++ b/bin/configs/java-okhttp-nullable-required.yaml
@@ -0,0 +1,11 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-nullable-required
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-nullable-required.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: gson
+ artifactId: nullable-required-okhttp
+ hideGenerationTimestamp: "true"
+ useOneOfDiscriminatorLookup: "true"
+ disallowAdditionalPropertiesIfNotPresent: false
diff --git a/bin/configs/java-okhttp-oneOf-array.yaml b/bin/configs/java-okhttp-oneOf-array.yaml
new file mode 100644
index 000000000000..56d479924df2
--- /dev/null
+++ b/bin/configs/java-okhttp-oneOf-array.yaml
@@ -0,0 +1,10 @@
+generatorName: java
+outputDir: samples/client/others/java/okhttp-oneOf-array
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_array.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: gson
+ artifactId: okhttp-oneOf-array
+ hideGenerationTimestamp: "true"
+ useBeanValidation: "true"
diff --git a/bin/configs/java-okhttp-oneOf.yaml b/bin/configs/java-okhttp-oneOf.yaml
new file mode 100644
index 000000000000..f69146f9255b
--- /dev/null
+++ b/bin/configs/java-okhttp-oneOf.yaml
@@ -0,0 +1,9 @@
+generatorName: java
+outputDir: samples/client/others/java/okhttp-oneOf
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_twoPrimitives.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: gson
+ artifactId: okhttp-oneOf
+ hideGenerationTimestamp: "true"
diff --git a/bin/configs/java-okhttp-parcelableModel.yaml b/bin/configs/java-okhttp-parcelableModel.yaml
new file mode 100644
index 000000000000..42ff08a8bb3c
--- /dev/null
+++ b/bin/configs/java-okhttp-parcelableModel.yaml
@@ -0,0 +1,10 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-parcelableModel
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: gson
+ parcelableModel: "true"
+ artifactId: petstore-okhttp-parcelableModel
+ hideGenerationTimestamp: "true"
diff --git a/bin/configs/java-okhttp-streaming.yaml b/bin/configs/java-okhttp-streaming.yaml
new file mode 100644
index 000000000000..5d6967c9e88b
--- /dev/null
+++ b/bin/configs/java-okhttp-streaming.yaml
@@ -0,0 +1,12 @@
+generatorName: java
+outputDir: samples/client/others/java/okhttp-streaming
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/streaming.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: gson
+ artifactId: petstore-okhttp
+ hideGenerationTimestamp: "true"
+ supportStreaming: true
+ serializableModel: true
+ enumPropertyNaming: legacy
diff --git a/bin/configs/java-okhttp-swagger1.yaml b/bin/configs/java-okhttp-swagger1.yaml
new file mode 100644
index 000000000000..af6cb35ae351
--- /dev/null
+++ b/bin/configs/java-okhttp-swagger1.yaml
@@ -0,0 +1,14 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-swagger1
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: gson
+ artifactId: petstore-okhttp
+ hideGenerationTimestamp: "true"
+ useOneOfDiscriminatorLookup: "true"
+ disallowAdditionalPropertiesIfNotPresent: false
+ annotationLibrary: "swagger1"
+openapiNormalizer:
+ SET_TAGS_FOR_ALL_OPERATIONS: common
diff --git a/bin/configs/java-okhttp-swagger2.yaml b/bin/configs/java-okhttp-swagger2.yaml
new file mode 100644
index 000000000000..a3e299695403
--- /dev/null
+++ b/bin/configs/java-okhttp-swagger2.yaml
@@ -0,0 +1,13 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp-swagger2
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+additionalProperties:
+ serializationLibrary: gson
+ artifactId: petstore-okhttp
+ hideGenerationTimestamp: "true"
+ useOneOfDiscriminatorLookup: "true"
+ disallowAdditionalPropertiesIfNotPresent: false
+ annotationLibrary: "swagger2"
+
diff --git a/bin/configs/java-okhttp-user-defined-templates.yaml b/bin/configs/java-okhttp-user-defined-templates.yaml
index 650c2dc1b195..93f7e91be1e9 100644
--- a/bin/configs/java-okhttp-user-defined-templates.yaml
+++ b/bin/configs/java-okhttp-user-defined-templates.yaml
@@ -1,9 +1,11 @@
generatorName: java
-outputDir: samples/client/echo_api/java/okhttp-gson-user-defined-templates
-library: okhttp-gson
-inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+outputDir: samples/client/echo_api/java/okhttp-user-defined-templates
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
+ serializationLibrary: gson
+ artifactId: echo-api-okhttp-user-defined-templates
hideGenerationTimestamp: "true"
files:
README.mustache:
diff --git a/bin/configs/java-okhttp.yaml b/bin/configs/java-okhttp.yaml
new file mode 100644
index 000000000000..b66e3711069c
--- /dev/null
+++ b/bin/configs/java-okhttp.yaml
@@ -0,0 +1,26 @@
+generatorName: java
+outputDir: samples/client/petstore/java/okhttp
+library: okhttp
+inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml
+templateDir: modules/openapi-generator/src/main/resources/Java
+nameMappings:
+ _type: underscoreType
+ type_: typeWithUnderscore
+parameterNameMappings:
+ _type: underscoreType
+ type_: typeWithUnderscore
+additionalProperties:
+ serializationLibrary: gson
+ defaultToEmptyContainer: "array?|array|map?"
+ artifactId: petstore-okhttp
+ hideGenerationTimestamp: true
+ useOneOfDiscriminatorLookup: true
+ disallowAdditionalPropertiesIfNotPresent: false
+ useReflectionEqualsHashCode: true
+ removeEnumValuePrefix: true
+enumNameMappings:
+ s: LOWER_CASE_S
+ S: UPPER_CASE_S
+operationIdNameMappings:
+ getArrayOfEnums: getFakeArrayofenums
+ fakeHealthGet: getFakeHealth
diff --git a/docs/generators/java-microprofile.md b/docs/generators/java-microprofile.md
index 2dfaf5e0bcf4..fb95e20f8283 100644
--- a/docs/generators/java-microprofile.md
+++ b/docs/generators/java-microprofile.md
@@ -64,7 +64,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|implicitHeadersRegex|Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true| |null|
|invokerPackage|root package for generated code| |org.openapitools.client|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|
- **true**
- The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
- **false**
- The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true|
-|library|library template (sub-template) to use|- **jersey2**
- HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.18.9
- **jersey3**
- HTTP client: Jersey client 3.1.11. JSON processing: Jackson 2.x (3.x if `useJackson3=true`, requires Java 17+)
- **feign**
- HTTP client: OpenFeign 13.2.1. JSON processing: Jackson 2.18.9 or Gson 2.10.1
- **feign-hc5**
- HTTP client: OpenFeign 13.2.1/HttpClient5 5.4.2. JSON processing: Jackson 2.18.9 or Gson 2.10.1
- **okhttp-gson**
- [DEFAULT] HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
- **retrofit2**
- HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1 (Retrofit 2.5.0) or Jackson 2.18.9. Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)
- **resttemplate**
- HTTP client: Spring RestTemplate 5.3.33 (6.2.x if `useJakartaEe=true`, 7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.x (3.x if `useJackson3=true`)
- **webclient**
- HTTP client: Spring WebClient 5.1.18 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)
- **restclient**
- HTTP client: Spring RestClient 6.1.6 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)
- **resteasy**
- HTTP client: Resteasy client 4.7.6. JSON processing: Jackson 2.18.9
- **vertx**
- HTTP client: VertX client 3.5.2. JSON processing: Jackson 2.18.9
- **google-api-client**
- HTTP client: Google API client 2.2.0. JSON processing: Jackson 2.18.9
- **rest-assured**
- HTTP client: rest-assured 5.3.2. JSON processing: Gson 2.10.1 or Jackson 2.18.9. Only for Java 8
- **native**
- HTTP client: Java native HttpClient. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`). Only for Java11+
- **microprofile**
- HTTP client: Microprofile client 2.0 (default, set desired version via `microprofileRestClientVersion=x.x.x`). JSON processing: JSON-B 1.0.2 or Jackson 2.18.9
- **apache-httpclient**
- HTTP client: Apache httpclient 5.2.1. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)
|okhttp-gson|
+|library|library template (sub-template) to use|- **jersey2**
- HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.18.9
- **jersey3**
- HTTP client: Jersey client 3.1.11. JSON processing: Jackson 2.x (3.x if `useJackson3=true`, requires Java 17+)
- **feign**
- HTTP client: OpenFeign 13.2.1. JSON processing: Jackson 2.18.9 or Gson 2.10.1
- **feign-hc5**
- HTTP client: OpenFeign 13.2.1/HttpClient5 5.4.2. JSON processing: Jackson 2.18.9 or Gson 2.10.1
- **okhttp-gson**
- [DEFAULT] HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
- **okhttp**
- [BETA] HTTP client: OkHttp 5.4.0. JSON processing: Gson 2.10.1 (default), Jackson 2.22.1 (3.2.1 if `useJackson3=true`) or JSON-B, selected via '-DserializationLibrary'. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
- **retrofit2**
- HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1 (Retrofit 2.5.0) or Jackson 2.18.9. Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)
- **resttemplate**
- HTTP client: Spring RestTemplate 5.3.33 (6.2.x if `useJakartaEe=true`, 7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.x (3.x if `useJackson3=true`)
- **webclient**
- HTTP client: Spring WebClient 5.1.18 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)
- **restclient**
- HTTP client: Spring RestClient 6.1.6 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)
- **resteasy**
- HTTP client: Resteasy client 4.7.6. JSON processing: Jackson 2.18.9
- **vertx**
- HTTP client: VertX client 3.5.2. JSON processing: Jackson 2.18.9
- **google-api-client**
- HTTP client: Google API client 2.2.0. JSON processing: Jackson 2.18.9
- **rest-assured**
- HTTP client: rest-assured 5.3.2. JSON processing: Gson 2.10.1 or Jackson 2.18.9. Only for Java 8
- **native**
- HTTP client: Java native HttpClient. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`). Only for Java11+
- **microprofile**
- HTTP client: Microprofile client 2.0 (default, set desired version via `microprofileRestClientVersion=x.x.x`). JSON processing: JSON-B 1.0.2 or Jackson 2.18.9
- **apache-httpclient**
- HTTP client: Apache httpclient 5.2.1. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)
|okhttp-gson|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|microprofileFramework|Framework for microprofile. Possible values "kumuluzee"| |null|
@@ -100,7 +100,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useGzipFeature|Send gzip-encoded requests| |false|
|useJackson3|Use Jackson 3 instead of Jackson 2. Supported for 'native', 'apache-httpclient', and 'jersey3' libraries (requires Java 17+) and for Spring 'resttemplate', 'webclient', and 'restclient' libraries (require useSpringBoot4=true).| |false|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
-|useJspecify|Use Jspecify for null checks. Only supported for [native, restclient, resttemplate, webclient]| |false|
+|useJspecify|Use Jspecify for null checks. Only supported for [native, okhttp, restclient, resttemplate, webclient]| |false|
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped. Only jersey2, jersey3, native, okhttp-gson support this option.| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|usePlayWS|Use Play! Async HTTP client (Play WS API)| |false|
diff --git a/docs/generators/java.md b/docs/generators/java.md
index 6740780102b9..733fb09ae5ad 100644
--- a/docs/generators/java.md
+++ b/docs/generators/java.md
@@ -64,7 +64,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|implicitHeadersRegex|Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true| |null|
|invokerPackage|root package for generated code| |org.openapitools.client|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|- **true**
- The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
- **false**
- The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true|
-|library|library template (sub-template) to use|- **jersey2**
- HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.18.9
- **jersey3**
- HTTP client: Jersey client 3.1.11. JSON processing: Jackson 2.x (3.x if `useJackson3=true`, requires Java 17+)
- **feign**
- HTTP client: OpenFeign 13.2.1. JSON processing: Jackson 2.18.9 or Gson 2.10.1
- **feign-hc5**
- HTTP client: OpenFeign 13.2.1/HttpClient5 5.4.2. JSON processing: Jackson 2.18.9 or Gson 2.10.1
- **okhttp-gson**
- [DEFAULT] HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
- **retrofit2**
- HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1 (Retrofit 2.5.0) or Jackson 2.18.9. Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)
- **resttemplate**
- HTTP client: Spring RestTemplate 5.3.33 (6.2.x if `useJakartaEe=true`, 7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.x (3.x if `useJackson3=true`)
- **webclient**
- HTTP client: Spring WebClient 5.1.18 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)
- **restclient**
- HTTP client: Spring RestClient 6.1.6 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)
- **resteasy**
- HTTP client: Resteasy client 4.7.6. JSON processing: Jackson 2.18.9
- **vertx**
- HTTP client: VertX client 3.5.2. JSON processing: Jackson 2.18.9
- **google-api-client**
- HTTP client: Google API client 2.2.0. JSON processing: Jackson 2.18.9
- **rest-assured**
- HTTP client: rest-assured 5.3.2. JSON processing: Gson 2.10.1 or Jackson 2.18.9. Only for Java 8
- **native**
- HTTP client: Java native HttpClient. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`). Only for Java11+
- **microprofile**
- HTTP client: Microprofile client 2.0 (default, set desired version via `microprofileRestClientVersion=x.x.x`). JSON processing: JSON-B 1.0.2 or Jackson 2.18.9
- **apache-httpclient**
- HTTP client: Apache httpclient 5.2.1. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)
|okhttp-gson|
+|library|library template (sub-template) to use|- **jersey2**
- HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.18.9
- **jersey3**
- HTTP client: Jersey client 3.1.11. JSON processing: Jackson 2.x (3.x if `useJackson3=true`, requires Java 17+)
- **feign**
- HTTP client: OpenFeign 13.2.1. JSON processing: Jackson 2.18.9 or Gson 2.10.1
- **feign-hc5**
- HTTP client: OpenFeign 13.2.1/HttpClient5 5.4.2. JSON processing: Jackson 2.18.9 or Gson 2.10.1
- **okhttp-gson**
- [DEFAULT] HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
- **okhttp**
- [BETA] HTTP client: OkHttp 5.4.0. JSON processing: Gson 2.10.1 (default), Jackson 2.22.1 (3.2.1 if `useJackson3=true`) or JSON-B, selected via '-DserializationLibrary'. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
- **retrofit2**
- HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1 (Retrofit 2.5.0) or Jackson 2.18.9. Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)
- **resttemplate**
- HTTP client: Spring RestTemplate 5.3.33 (6.2.x if `useJakartaEe=true`, 7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.x (3.x if `useJackson3=true`)
- **webclient**
- HTTP client: Spring WebClient 5.1.18 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)
- **restclient**
- HTTP client: Spring RestClient 6.1.6 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)
- **resteasy**
- HTTP client: Resteasy client 4.7.6. JSON processing: Jackson 2.18.9
- **vertx**
- HTTP client: VertX client 3.5.2. JSON processing: Jackson 2.18.9
- **google-api-client**
- HTTP client: Google API client 2.2.0. JSON processing: Jackson 2.18.9
- **rest-assured**
- HTTP client: rest-assured 5.3.2. JSON processing: Gson 2.10.1 or Jackson 2.18.9. Only for Java 8
- **native**
- HTTP client: Java native HttpClient. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`). Only for Java11+
- **microprofile**
- HTTP client: Microprofile client 2.0 (default, set desired version via `microprofileRestClientVersion=x.x.x`). JSON processing: JSON-B 1.0.2 or Jackson 2.18.9
- **apache-httpclient**
- HTTP client: Apache httpclient 5.2.1. JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)
|okhttp-gson|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|microprofileFramework|Framework for microprofile. Possible values "kumuluzee"| |null|
@@ -100,7 +100,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useGzipFeature|Send gzip-encoded requests| |false|
|useJackson3|Use Jackson 3 instead of Jackson 2. Supported for 'native', 'apache-httpclient', and 'jersey3' libraries (requires Java 17+) and for Spring 'resttemplate', 'webclient', and 'restclient' libraries (require useSpringBoot4=true).| |false|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
-|useJspecify|Use Jspecify for null checks. Only supported for [native, restclient, resttemplate, webclient]| |false|
+|useJspecify|Use Jspecify for null checks. Only supported for [native, okhttp, restclient, resttemplate, webclient]| |false|
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped. Only jersey2, jersey3, native, okhttp-gson support this option.| |false|
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
|usePlayWS|Use Play! Async HTTP client (Play WS API)| |false|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
index 6f6cb0af8471..30c25e69af0e 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
@@ -100,6 +100,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
public static final String JERSEY3 = "jersey3";
public static final String NATIVE = "native";
public static final String OKHTTP_GSON = "okhttp-gson";
+ public static final String OKHTTP = "okhttp";
public static final String RESTEASY = "resteasy";
public static final String RESTTEMPLATE = "resttemplate";
public static final String WEBCLIENT = "webclient";
@@ -189,7 +190,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
@Setter protected int maxAttemptsForRetry = 1;
@Setter protected long waitTimeMillis = 10l;
- private final Set JSPECIFY_SUPPORTED_LIBRARIES = new TreeSet<>(Arrays.asList(RESTCLIENT, WEBCLIENT, NATIVE, RESTTEMPLATE));
+ private final Set JSPECIFY_SUPPORTED_LIBRARIES = new TreeSet<>(Arrays.asList(RESTCLIENT, WEBCLIENT, NATIVE, RESTTEMPLATE, OKHTTP));
private static class MpRestClientVersion {
public final String rootPackage;
@@ -297,6 +298,7 @@ public JavaClientCodegen() {
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 13.2.1. JSON processing: Jackson 2.18.9 or Gson 2.10.1");
supportedLibraries.put(FEIGN_HC5, "HTTP client: OpenFeign 13.2.1/HttpClient5 5.4.2. JSON processing: Jackson 2.18.9 or Gson 2.10.1");
supportedLibraries.put(OKHTTP_GSON, "[DEFAULT] HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
+ supportedLibraries.put(OKHTTP, "[BETA] HTTP client: OkHttp 5.4.0. JSON processing: Gson 2.10.1 (default), Jackson 2.22.1 (3.2.1 if `useJackson3=true`) or JSON-B, selected via '-DserializationLibrary'. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 4.11.0. JSON processing: Gson 2.10.1 (Retrofit 2.5.0) or Jackson 2.18.9. Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)");
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 5.3.33 (6.2.x if `useJakartaEe=true`, 7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.x (3.x if `useJackson3=true`)");
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.1.18 (7.x.x if `useSpringBoot4=true`). JSON processing: Jackson 2.18.9 (3.x if `useJackson3=true`)");
@@ -390,6 +392,7 @@ public void processOpts() {
final boolean libJersey3 = isLibrary(JERSEY3);
final boolean libMicroprofile = isLibrary(MICROPROFILE);
final boolean libNative = isLibrary(NATIVE);
+ final boolean libOkHttp = isLibrary(OKHTTP);
final boolean libOkHttpGson = isLibrary(OKHTTP_GSON) || StringUtils.isBlank(getLibrary());
final boolean libRestAssured = isLibrary(REST_ASSURED);
final boolean libRestClient = isLibrary(RESTCLIENT);
@@ -407,8 +410,8 @@ public void processOpts() {
convertPropertyToBooleanAndWriteBack(USE_SPRING_BOOT4, this::setUseSpringBoot4);
if (useJackson3 && (libRestClient || libRestTemplate || libWebClient) && !useSpringBoot4) {
throw new IllegalArgumentException("useJackson3 for the restclient, resttemplate, and webclient libraries requires useSpringBoot4=true");
- } else if (useJackson3 && !libNative && !libApache && !libJersey3 && !libRestClient && !libRestTemplate && !libWebClient) {
- throw new IllegalArgumentException("useJackson3 is only supported for the 'native', 'apache-httpclient', 'jersey3', 'restclient', 'resttemplate', and 'webclient' libraries. " +
+ } else if (useJackson3 && !libNative && !libApache && !libJersey3 && !libOkHttp && !libRestClient && !libRestTemplate && !libWebClient) {
+ throw new IllegalArgumentException("useJackson3 is only supported for the 'native', 'apache-httpclient', 'jersey3', 'okhttp', 'restclient', 'resttemplate', and 'webclient' libraries. " +
"The Spring libraries also require useSpringBoot4=true.");
}
@@ -572,7 +575,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.mustache", authFolder, "HttpBasicAuth.java"));
supportingFiles.add(new SupportingFile("auth/HttpBearerAuth.mustache", authFolder, "HttpBearerAuth.java"));
supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java"));
- if (libOkHttpGson && withAWSV4Signature) {
+ if ((libOkHttpGson || libOkHttp) && withAWSV4Signature) {
supportingFiles.add(new SupportingFile("auth/AWS4Auth.mustache", authFolder, "AWS4Auth.java"));
}
}
@@ -637,8 +640,8 @@ public void processOpts() {
// The flag below should be set for all Java libraries, but the templates need to be ported
// one by one for each library.
supportsAdditionalPropertiesWithComposedSchema = true;
- } else if (libOkHttpGson) {
- // the "okhttp-gson" library template requires "ApiCallback.mustache" for async call
+ } else if (libOkHttpGson || libOkHttp) {
+ // the "okhttp-gson" and "okhttp" library templates require "ApiCallback.mustache" for async call
supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java"));
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
@@ -650,7 +653,12 @@ public void processOpts() {
// NOTE: below moved to postProcessOperationsWithModels
//supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
//supportingFiles.add(new SupportingFile("auth/RetryingOAuth.mustache", authFolder, "RetryingOAuth.java"));
- forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
+
+ // "okhttp-gson" is Gson-only by definition; "okhttp" drives Gson, Jackson and JSON-B from
+ // the same templates, so it must keep whatever serializationLibrary the user asked for.
+ if (libOkHttpGson) {
+ forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
+ }
// Composed schemas can have the 'additionalProperties' keyword, as specified in JSON schema.
// In principle, this should be enabled by default for all code generators. However due to limitations
@@ -871,6 +879,13 @@ public void processOpts() {
additionalProperties.put(SERIALIZATION_LIBRARY_JSONB, "true");
additionalProperties.remove(SERIALIZATION_LIBRARY_JACKSON);
additionalProperties.remove(SERIALIZATION_LIBRARY_GSON);
+ if (libOkHttp) {
+ // openApiNullable is Jackson-only (it is jackson-databind-nullable). The okhttp pom
+ // already omits that dependency for JSON-B, so leaving the flag on emits JsonNullable
+ // references that cannot resolve.
+ openApiNullable = false;
+ additionalProperties.put(OPENAPI_NULLABLE, false);
+ }
break;
default:
additionalProperties.remove(SERIALIZATION_LIBRARY_JACKSON);
@@ -879,6 +894,15 @@ public void processOpts() {
break;
}
+ if (libOkHttp) {
+ // The okhttp templates emit Gson, Jackson or JSON-B from one source, so they need the
+ // resolved serialization library as three mutually exclusive mustache flags. This must run
+ // after the switch above, which is where getSerializationLibrary() becomes authoritative.
+ additionalProperties.put("isGson", SERIALIZATION_LIBRARY_GSON.equals(getSerializationLibrary()));
+ additionalProperties.put("isJackson", SERIALIZATION_LIBRARY_JACKSON.equals(getSerializationLibrary()));
+ additionalProperties.put("isJsonb", SERIALIZATION_LIBRARY_JSONB.equals(getSerializationLibrary()));
+ }
+
if (isLibrary(FEIGN)) {
additionalProperties.put("feign-okhttp", "true");
} else if (isLibrary(FEIGN_HC5)) {
@@ -900,6 +924,10 @@ public void processOpts() {
if (libOkHttpGson) {
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
supportingFiles.add(new SupportingFile("auth/RetryingOAuth.mustache", authFolder, "RetryingOAuth.java"));
+ } else if (libOkHttp) {
+ // okhttp's RetryingOAuth is self-contained (it embeds TokenRequestBuilder and talks to
+ // OkHttp directly), so it needs neither OAuthOkHttpClient nor the Apache Oltu dependency.
+ supportingFiles.add(new SupportingFile("auth/RetryingOAuth.mustache", authFolder, "RetryingOAuth.java"));
}
// google-api-client doesn't use the OpenAPI auth, because it uses Google Credential directly (HttpRequestInitializer)
@@ -922,7 +950,7 @@ public void processOpts() {
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List allModels) {
super.postProcessOperationsWithModels(objs, allModels);
- if (this.getSingleRequestParameter() && (isLibrary(JERSEY2) || isLibrary(JERSEY3) || isLibrary(OKHTTP_GSON) || isLibrary(NATIVE))) {
+ if (this.getSingleRequestParameter() && (isLibrary(JERSEY2) || isLibrary(JERSEY3) || isLibrary(OKHTTP_GSON) || isLibrary(OKHTTP) || isLibrary(NATIVE))) {
// loop through operations to set x-group-parameters extension to true if useSingleRequestParameter option is enabled
OperationMap operations = objs.getOperations();
if (operations != null) {
@@ -1126,7 +1154,11 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
model.imports.add("JsonProperty");
model.imports.add("JsonValue");
model.imports.add("JsonInclude");
- if (!useJackson3) {
+ // The okhttp pojo template emits @JsonTypeName for Jackson 3 too, so it needs the
+ // import on every model. Routing it through model.imports (a Set) rather than
+ // hardcoding it in the template keeps it from being emitted twice on the models
+ // that AbstractJavaCodegen already imports it for.
+ if (!useJackson3 || isLibrary(OKHTTP)) {
model.imports.add("JsonTypeName");
}
}
@@ -1224,7 +1256,11 @@ public ModelsMap postProcessModels(ModelsMap objs) {
objs = super.postProcessModels(objs);
List models = objs.getModels();
- if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON)) {
+ // The x-enum-as-string rewrite below is not a Jackson nicety: a child schema that narrows an
+ // inherited discriminator to a single-value enum otherwise generates a getter that cannot
+ // override the parent's String getter. The okhttp library drives Gson, Jackson and JSON-B from
+ // one set of templates, so it needs the rewrite for every serialization library.
+ if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON) || isLibrary(OKHTTP)) {
List