diff --git a/README.md b/README.md
index 2d9c97f0fb0..3a443c0258d 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ so developers can use all of those features.
Currently, the following languages/frameworks are supported:
- python (Stability: Stable)
-- java (Stability: Experimental)
+- java (Stability: Stable)
## Join Our Community
We use a Discord server as a place to ask questions and help each other. It offers functionality very similar to Slack.
@@ -49,7 +49,7 @@ You can join us here: https://discord.gg/mHB8WEQuYQ
- Invalid (in python) property names supported like `from`, `1var`, `hi-there` etc in
- schema property names
- endpoint parameter names
-- Payload values are not coerced when validated, so a datetime value can pass other validations that describe the payload only as type string
+- Payload values are not coerced when validated, so a date/date-time value can pass other validations that describe the payload only as type string
- types are generated for enums of type string/integer/boolean using typing.Literal
- String transmission of numbers supported with type: string, format: number, value can be accessed as a Decimal with schemas.as_decimal(inst)
- Multiple content types supported for request and response bodies
@@ -67,11 +67,9 @@ And many more!
## Reasons To Use the Java Generator
-- v3.0.0 - [v3.1.0](docs/generators/java.md#schema-feature) OpenAPI Specification support for component schemas
-- Very [thorough documentation generated in the style of javadocs, includes code samples](samples/client/petstore/java/docs/components/schemas/Money.md#money)
-- Sealed classes used to define different endpoint responses.
- Sealed classes used to define different response body classes.
- Endpoint code samples include exhaustive handling of the sealed classes.
+- v3.0.0 - [v3.1.0](docs/generators/java.md#schema-feature) OpenAPI Specification support
+- Documentation generated in the style of javadocs. Examples: [Money schema](samples/client/petstore/java/docs/components/schemas/Money.md#money1) [Pet.addPet endpoint](samples/client/petstore/java/docs/apis/tags/Pet.md#addpet)
+- Sealed classes used to define endpoint responses/response bodies/validated schema payloads/request bodies
- Input types constrained for a Schema in SomeSchema.validate
- validate method can accept arbitrary List/Map/null/int/long/double/float/String json data
- Immutable List output classes generated and returned by validate for List<?> input
@@ -95,8 +93,8 @@ And many more!
- Generated interfaces are largely consistent with the python code
- Openapi spec inline schemas supported at any depth in any location
- Format support for: int32, int64, float, double, date, datetime, uuid
-- Payload values are not coerced when validated, so a datetime value can pass other validations that describe the payload only as type string
-- types are generated for enums of type string/number/integer/boolean/null
+- Payload values are not coerced when validated, so a date/date-time value can pass other validations that describe the payload only as type string
+- enum types are generated for enums of type string/integer/number/boolean/null
- String transmission of numbers supported with type: string, format: number
- [Autogenerated thorough testing of json schema keyword features in models and endpoints](samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas) which come from the [json schema test suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite)
- [Tests are passing in CI](https://app.circleci.com/pipelines/github/openapi-json-schema-tools/openapi-json-schema-generator?branch=master)
diff --git a/docs/generators/java.md b/docs/generators/java.md
index 83844d3c5fa..f9efbabe28f 100644
--- a/docs/generators/java.md
+++ b/docs/generators/java.md
@@ -7,12 +7,12 @@ title: Documentation for the java generator
| Property | Value | Notes |
| -------- | ----- | ----- |
| generator name | java | pass this to the generate command after -g |
-| generator stability | EXPERIMENTAL | |
+| generator stability | STABLE | |
| generator type | CLIENT | |
| generator language | Java | |
| generator language version | 17 | |
| generator default templating engine | handlebars | |
-| helpTxt | Generates a Java client library
Features in this generator:
- v3.0.0 - [v3.0.3](#schema-feature) OpenAPI Specification support for component schemas
- Very [thorough documentation generated in the style of javadocs, includes code samples](samples/client/petstore/java/docs/components/schemas/Money.md#money)
- Input types constrained for a Schema in SomeSchema.validate
- validate method can accept arbitrary List/Map/null/int/long/double/float/String json data
- Immutable List output classes generated and returned by validate for List<?> input
- Immutable Map output classes generated and returned by validate for Map<?, ?> input
- Strictly typed list input can be instantiated in client code using generated ListBuilders
- Strictly typed map input can be instantiated in client code using generated MapBuilders
- Sequential map builders are generated ensuring that required properties are set before build is invoked. Looks like:
- `new MapBuilder().requiredA("a").requiredB("b").build()`
- `new MapBuilder().requiredA("a").requiredB("b").optionalProp("c").additionalProperty("someAddProp", "d").build()`
- Run time type checking and validation when
- validating schema payloads
- instantiating List output class (validation run)
- instantiating Map output class (validation run)
- Note: if needed, validation of json schema keywords can be deactivated via a SchemaConfiguration class
- Enums classes are generated and may be input into Schema.validate or the List/MapBuilder add/setter methods
- The [Checker-Framework's](https://github.com/typetools/checker-framework) NullnessChecker and @Nullable annotations are used in the java client
- ensuring that null pointer exceptions will not happen
- Invalid (in java) property names supported like `class`, `1var`, `hi-there` etc in
- component schema names
- schema property names (a fallback setter is written in the MapBuilder)
- Generated interfaces are largely consistent with the python code
- Openapi spec inline schemas supported at any depth in any location
- Format support for: int32, int64, float, double, date, datetime, uuid
- Payload values are not coerced when validated, so a datetime value can pass other validations that describe the payload only as type string
- types are generated for enums of type string/integer/boolean using typing.Literal
- String transmission of numbers supported with type: string, format: number | |
+| helpTxt | Generates a Java client library
Features in this generator:
- v3.0.0 - [v3.1.0](#schema-feature) OpenAPI Specification support
- Very thorough documentation generated in the style of javadocs
- Input types constrained for a Schema in SomeSchema.validate
- validate method can accept arbitrary List/Map/null/int/long/double/float/String json data
- Immutable List output classes generated and returned by validate for List<?> input
- Immutable Map output classes generated and returned by validate for Map<?, ?> input
- Strictly typed list input can be instantiated in client code using generated ListBuilders
- Strictly typed map input can be instantiated in client code using generated MapBuilders
- Sequential map builders are generated ensuring that required properties are set before build is invoked. Looks like:
- `new MapBuilder().requiredA("a").requiredB("b").build()`
- `new MapBuilder().requiredA("a").requiredB("b").optionalProp("c").additionalProperty("someAddProp", "d").build()`
- Run time type checking and validation when
- validating schema payloads
- instantiating List output class (validation run)
- instantiating Map output class (validation run)
- Note: if needed, validation of json schema keywords can be deactivated via a SchemaConfiguration class
- Enums classes are generated and may be input into Schema.validate or the List/MapBuilder add/setter methods
- The [Checker-Framework's](https://github.com/typetools/checker-framework) NullnessChecker and @Nullable annotations are used in the java client
- ensuring that null pointer exceptions will not happen
- Invalid (in java) property names supported like `class`, `1var`, `hi-there` etc in
- component schema names
- schema property names (a fallback setter is written in the MapBuilder)
- Generated interfaces are largely consistent with the python code
- Openapi spec inline schemas supported at any depth in any location
- Format support for: int32, int64, float, double, date, datetime, uuid
- Payload values are not coerced when validated, so a date/date-time value can pass other validations that describe the payload only as type string
- enum types are generated for enums of type string/integer/number/boolean/null
- String transmission of numbers supported with type: string, format: number | |
## CONFIG OPTIONS
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
@@ -218,7 +218,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| ---- | --------- | ---------- |
|Readme|✓|ToolingExtension
|Servers|✓|OAS3
-|Security|✗|OAS2,OAS3
+|Security|✓|OAS2,OAS3
|ComponentSchemas|✓|OAS3
|ComponentResponses|✓|OAS3
|ComponentParameters|✓|OAS3
@@ -228,7 +228,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|ComponentLinks|✗|OAS3
|ComponentCallbacks|✗|OAS3
|ComponentPathItems|✗|OAS3
-|Api|✗|ToolingExtension
+|Api|✓|ToolingExtension
### Global Feature
| Name | Supported | Defined By |
diff --git a/pom.xml b/pom.xml
index 3b4c68fe037..0895436d3dd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -446,7 +446,7 @@
- 4.1.3
+ 4.2.0
UTF-8
11
diff --git a/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java b/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java
index 17fe83c6df8..0bc94b8281a 100644
--- a/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java
+++ b/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java
@@ -117,7 +117,7 @@ public class JavaClientGenerator extends DefaultGenerator implements Generator {
private final Map schemaKeyToModelNameCache = new HashMap<>();
protected Stability getStability() {
- return Stability.EXPERIMENTAL;
+ return Stability.STABLE;
}
@Override
@@ -259,87 +259,89 @@ public JavaClientGenerator() {
instantiationTypes.put("null", "Void (null)");
modifyFeatureSet(features -> features
- .includeDocumentationFeatures(
- DocumentationFeature.Readme,
- DocumentationFeature.Servers,
- DocumentationFeature.ComponentSchemas,
- DocumentationFeature.ComponentSecuritySchemes,
- DocumentationFeature.ComponentRequestBodies,
- DocumentationFeature.ComponentResponses,
- DocumentationFeature.ComponentHeaders,
- DocumentationFeature.ComponentParameters
- )
- .includeGlobalFeatures(
- GlobalFeature.Components,
- GlobalFeature.Servers,
- GlobalFeature.Security,
- GlobalFeature.Paths
- )
- .includeComponentsFeatures(
- ComponentsFeature.schemas,
- ComponentsFeature.securitySchemes,
- ComponentsFeature.requestBodies,
- ComponentsFeature.responses,
- ComponentsFeature.headers,
- ComponentsFeature.parameters
- )
- .includeSecurityFeatures(
- SecurityFeature.ApiKey,
- SecurityFeature.HTTP_Basic,
- SecurityFeature.HTTP_Bearer
- )
- .includeOperationFeatures(
- OperationFeature.Security,
- OperationFeature.Servers,
- OperationFeature.Responses_Default,
- OperationFeature.Responses_HttpStatusCode,
- OperationFeature.Responses_RangedResponseCodes,
- OperationFeature.Responses_RedirectionResponse
- )
- .includeSchemaFeatures(
- SchemaFeature.AdditionalProperties,
- SchemaFeature.AllOf,
- SchemaFeature.AnyOf,
- SchemaFeature.Const,
- SchemaFeature.Contains,
- SchemaFeature.Default,
- SchemaFeature.DependentRequired,
- SchemaFeature.DependentSchemas,
- // SchemaFeature.Discriminator,
- SchemaFeature.Else,
- SchemaFeature.Enum,
- SchemaFeature.ExclusiveMaximum,
- SchemaFeature.ExclusiveMinimum,
- SchemaFeature.Format,
- SchemaFeature.If,
- SchemaFeature.Items,
- SchemaFeature.MaxContains,
- SchemaFeature.MaxItems,
- SchemaFeature.MaxLength,
- SchemaFeature.MaxProperties,
- SchemaFeature.Maximum,
- SchemaFeature.MinContains,
- SchemaFeature.MinItems,
- SchemaFeature.MinLength,
- SchemaFeature.MinProperties,
- SchemaFeature.Minimum,
- SchemaFeature.MultipleOf,
- SchemaFeature.Not,
- SchemaFeature.Nullable,
- SchemaFeature.OneOf,
- SchemaFeature.Pattern,
- SchemaFeature.PatternProperties,
- SchemaFeature.PrefixItems,
- SchemaFeature.Properties,
- SchemaFeature.PropertyNames,
- SchemaFeature.Ref,
- SchemaFeature.Required,
- SchemaFeature.Then,
- SchemaFeature.Type,
- SchemaFeature.UnevaluatedItems,
- SchemaFeature.UnevaluatedProperties,
- SchemaFeature.UniqueItems
- )
+ .includeDocumentationFeatures(
+ DocumentationFeature.Readme,
+ DocumentationFeature.Servers,
+ DocumentationFeature.Security,
+ DocumentationFeature.ComponentSchemas,
+ DocumentationFeature.ComponentSecuritySchemes,
+ DocumentationFeature.ComponentRequestBodies,
+ DocumentationFeature.ComponentResponses,
+ DocumentationFeature.ComponentHeaders,
+ DocumentationFeature.ComponentParameters,
+ DocumentationFeature.Api
+ )
+ .includeGlobalFeatures(
+ GlobalFeature.Components,
+ GlobalFeature.Servers,
+ GlobalFeature.Security,
+ GlobalFeature.Paths
+ )
+ .includeComponentsFeatures(
+ ComponentsFeature.schemas,
+ ComponentsFeature.securitySchemes,
+ ComponentsFeature.requestBodies,
+ ComponentsFeature.responses,
+ ComponentsFeature.headers,
+ ComponentsFeature.parameters
+ )
+ .includeSecurityFeatures(
+ SecurityFeature.ApiKey,
+ SecurityFeature.HTTP_Basic,
+ SecurityFeature.HTTP_Bearer
+ )
+ .includeOperationFeatures(
+ OperationFeature.Security,
+ OperationFeature.Servers,
+ OperationFeature.Responses_Default,
+ OperationFeature.Responses_HttpStatusCode,
+ OperationFeature.Responses_RangedResponseCodes,
+ OperationFeature.Responses_RedirectionResponse
+ )
+ .includeSchemaFeatures(
+ SchemaFeature.AdditionalProperties,
+ SchemaFeature.AllOf,
+ SchemaFeature.AnyOf,
+ SchemaFeature.Const,
+ SchemaFeature.Contains,
+ SchemaFeature.Default,
+ SchemaFeature.DependentRequired,
+ SchemaFeature.DependentSchemas,
+ // SchemaFeature.Discriminator,
+ SchemaFeature.Else,
+ SchemaFeature.Enum,
+ SchemaFeature.ExclusiveMaximum,
+ SchemaFeature.ExclusiveMinimum,
+ SchemaFeature.Format,
+ SchemaFeature.If,
+ SchemaFeature.Items,
+ SchemaFeature.MaxContains,
+ SchemaFeature.MaxItems,
+ SchemaFeature.MaxLength,
+ SchemaFeature.MaxProperties,
+ SchemaFeature.Maximum,
+ SchemaFeature.MinContains,
+ SchemaFeature.MinItems,
+ SchemaFeature.MinLength,
+ SchemaFeature.MinProperties,
+ SchemaFeature.Minimum,
+ SchemaFeature.MultipleOf,
+ SchemaFeature.Not,
+ SchemaFeature.Nullable,
+ SchemaFeature.OneOf,
+ SchemaFeature.Pattern,
+ SchemaFeature.PatternProperties,
+ SchemaFeature.PrefixItems,
+ SchemaFeature.Properties,
+ SchemaFeature.PropertyNames,
+ SchemaFeature.Ref,
+ SchemaFeature.Required,
+ SchemaFeature.Then,
+ SchemaFeature.Type,
+ SchemaFeature.UnevaluatedItems,
+ SchemaFeature.UnevaluatedProperties,
+ SchemaFeature.UniqueItems
+ )
);
outputFolder = "generated-code" + File.separator + "java";
@@ -378,8 +380,8 @@ public String getHelp() {
"Generates a Java client library",
"",
"Features in this generator:",
- "- v3.0.0 - [v3.0.3](#schema-feature) OpenAPI Specification support for component schemas",
- "- Very [thorough documentation generated in the style of javadocs, includes code samples](samples/client/petstore/java/docs/components/schemas/Money.md#money)",
+ "- v3.0.0 - [v3.1.0](#schema-feature) OpenAPI Specification support",
+ "- Very thorough documentation generated in the style of javadocs",
"- Input types constrained for a Schema in SomeSchema.validate",
" - validate method can accept arbitrary List/Map/null/int/long/double/float/String json data",
"- Immutable List output classes generated and returned by validate for List<?> input",
@@ -403,8 +405,8 @@ public String getHelp() {
"- Generated interfaces are largely consistent with the python code",
"- Openapi spec inline schemas supported at any depth in any location",
"- Format support for: int32, int64, float, double, date, datetime, uuid",
- "- Payload values are not coerced when validated, so a datetime value can pass other validations that describe the payload only as type string",
- "- types are generated for enums of type string/integer/boolean using typing.Literal",
+ "- Payload values are not coerced when validated, so a date/date-time value can pass other validations that describe the payload only as type string",
+ "- enum types are generated for enums of type string/integer/number/boolean/null",
"- String transmission of numbers supported with type: string, format: number"
);
}