Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 8d450fb

Browse files
authored
Java generator changed to stable status, version updated to 4.2.0 (#422)
* Java generator changed to stable status, version rev rolled * Adjusts coercion language
1 parent 8ee7043 commit 8d450fb

File tree

4 files changed

+100
-100
lines changed

4 files changed

+100
-100
lines changed

README.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ so developers can use all of those features.
1616
Currently, the following languages/frameworks are supported:
1717

1818
- python (Stability: Stable)
19-
- java (Stability: Experimental)
19+
- java (Stability: Stable)
2020

2121
## Join Our Community
2222
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
4949
- Invalid (in python) property names supported like `from`, `1var`, `hi-there` etc in
5050
- schema property names
5151
- endpoint parameter names
52-
- Payload values are not coerced when validated, so a datetime value can pass other validations that describe the payload only as type string
52+
- 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
5353
- types are generated for enums of type string/integer/boolean using typing.Literal
5454
- String transmission of numbers supported with type: string, format: number, value can be accessed as a Decimal with schemas.as_decimal(inst)
5555
- Multiple content types supported for request and response bodies
@@ -67,11 +67,9 @@ And many more!
6767

6868
## Reasons To Use the Java Generator
6969

70-
- v3.0.0 - [v3.1.0](docs/generators/java.md#schema-feature) OpenAPI Specification support for component schemas
71-
- Very [thorough documentation generated in the style of javadocs, includes code samples](samples/client/petstore/java/docs/components/schemas/Money.md#money)
72-
- Sealed classes used to define different endpoint responses.
73-
Sealed classes used to define different response body classes.
74-
Endpoint code samples include exhaustive handling of the sealed classes.
70+
- v3.0.0 - [v3.1.0](docs/generators/java.md#schema-feature) OpenAPI Specification support
71+
- 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)
72+
- Sealed classes used to define endpoint responses/response bodies/validated schema payloads/request bodies
7573
- Input types constrained for a Schema in SomeSchema.validate
7674
- validate method can accept arbitrary List/Map/null/int/long/double/float/String json data
7775
- Immutable List output classes generated and returned by validate for List<?> input
@@ -95,8 +93,8 @@ And many more!
9593
- Generated interfaces are largely consistent with the python code
9694
- Openapi spec inline schemas supported at any depth in any location
9795
- Format support for: int32, int64, float, double, date, datetime, uuid
98-
- Payload values are not coerced when validated, so a datetime value can pass other validations that describe the payload only as type string
99-
- types are generated for enums of type string/number/integer/boolean/null
96+
- 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
97+
- enum types are generated for enums of type string/integer/number/boolean/null
10098
- String transmission of numbers supported with type: string, format: number
10199
- [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)
102100
- [Tests are passing in CI](https://app.circleci.com/pipelines/github/openapi-json-schema-tools/openapi-json-schema-generator?branch=master)

docs/generators/java.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ title: Documentation for the java generator
77
| Property | Value | Notes |
88
| -------- | ----- | ----- |
99
| generator name | java | pass this to the generate command after -g |
10-
| generator stability | EXPERIMENTAL | |
10+
| generator stability | STABLE | |
1111
| generator type | CLIENT | |
1212
| generator language | Java | |
1313
| generator language version | 17 | |
1414
| generator default templating engine | handlebars | |
15-
| helpTxt | Generates a Java client library<br /><br />Features in this generator:<br />- v3.0.0 - [v3.0.3](#schema-feature) OpenAPI Specification support for component schemas<br />- Very [thorough documentation generated in the style of javadocs, includes code samples](samples/client/petstore/java/docs/components/schemas/Money.md#money)<br />- Input types constrained for a Schema in SomeSchema.validate<br /> - validate method can accept arbitrary List/Map/null/int/long/double/float/String json data<br />- Immutable List output classes generated and returned by validate for List&lt;?&gt; input<br />- Immutable Map output classes generated and returned by validate for Map&lt;?, ?&gt; input<br />- Strictly typed list input can be instantiated in client code using generated ListBuilders<br />- Strictly typed map input can be instantiated in client code using generated MapBuilders<br /> - Sequential map builders are generated ensuring that required properties are set before build is invoked. Looks like:<br /> - `new MapBuilder().requiredA("a").requiredB("b").build()`<br /> - `new MapBuilder().requiredA("a").requiredB("b").optionalProp("c").additionalProperty("someAddProp", "d").build()`<br />- Run time type checking and validation when<br /> - validating schema payloads<br /> - instantiating List output class (validation run)<br /> - instantiating Map output class (validation run)<br /> - Note: if needed, validation of json schema keywords can be deactivated via a SchemaConfiguration class<br />- Enums classes are generated and may be input into Schema.validate or the List/MapBuilder add/setter methods<br />- The [Checker-Framework's](https://github.com/typetools/checker-framework) NullnessChecker and @Nullable annotations are used in the java client<br /> - ensuring that null pointer exceptions will not happen<br />- Invalid (in java) property names supported like `class`, `1var`, `hi-there` etc in<br /> - component schema names<br /> - schema property names (a fallback setter is written in the MapBuilder)<br />- Generated interfaces are largely consistent with the python code<br />- Openapi spec inline schemas supported at any depth in any location<br />- Format support for: int32, int64, float, double, date, datetime, uuid<br />- Payload values are not coerced when validated, so a datetime value can pass other validations that describe the payload only as type string<br />- types are generated for enums of type string/integer/boolean using typing.Literal<br />- String transmission of numbers supported with type: string, format: number | |
15+
| helpTxt | Generates a Java client library<br /><br />Features in this generator:<br />- v3.0.0 - [v3.1.0](#schema-feature) OpenAPI Specification support<br />- Very thorough documentation generated in the style of javadocs<br />- Input types constrained for a Schema in SomeSchema.validate<br /> - validate method can accept arbitrary List/Map/null/int/long/double/float/String json data<br />- Immutable List output classes generated and returned by validate for List&lt;?&gt; input<br />- Immutable Map output classes generated and returned by validate for Map&lt;?, ?&gt; input<br />- Strictly typed list input can be instantiated in client code using generated ListBuilders<br />- Strictly typed map input can be instantiated in client code using generated MapBuilders<br /> - Sequential map builders are generated ensuring that required properties are set before build is invoked. Looks like:<br /> - `new MapBuilder().requiredA("a").requiredB("b").build()`<br /> - `new MapBuilder().requiredA("a").requiredB("b").optionalProp("c").additionalProperty("someAddProp", "d").build()`<br />- Run time type checking and validation when<br /> - validating schema payloads<br /> - instantiating List output class (validation run)<br /> - instantiating Map output class (validation run)<br /> - Note: if needed, validation of json schema keywords can be deactivated via a SchemaConfiguration class<br />- Enums classes are generated and may be input into Schema.validate or the List/MapBuilder add/setter methods<br />- The [Checker-Framework's](https://github.com/typetools/checker-framework) NullnessChecker and @Nullable annotations are used in the java client<br /> - ensuring that null pointer exceptions will not happen<br />- Invalid (in java) property names supported like `class`, `1var`, `hi-there` etc in<br /> - component schema names<br /> - schema property names (a fallback setter is written in the MapBuilder)<br />- Generated interfaces are largely consistent with the python code<br />- Openapi spec inline schemas supported at any depth in any location<br />- Format support for: int32, int64, float, double, date, datetime, uuid<br />- 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<br />- enum types are generated for enums of type string/integer/number/boolean/null<br />- String transmission of numbers supported with type: string, format: number | |
1616

1717
## CONFIG OPTIONS
1818
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
218218
| ---- | --------- | ---------- |
219219
|Readme|✓|ToolingExtension
220220
|Servers|✓|OAS3
221-
|Security||OAS2,OAS3
221+
|Security||OAS2,OAS3
222222
|ComponentSchemas|✓|OAS3
223223
|ComponentResponses|✓|OAS3
224224
|ComponentParameters|✓|OAS3
@@ -228,7 +228,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
228228
|ComponentLinks|✗|OAS3
229229
|ComponentCallbacks|✗|OAS3
230230
|ComponentPathItems|✗|OAS3
231-
|Api||ToolingExtension
231+
|Api||ToolingExtension
232232

233233
### Global Feature
234234
| Name | Supported | Defined By |

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@
446446
</dependencies>
447447
<properties>
448448
<!-- RELEASE_VERSION -->
449-
<revision>4.1.3</revision>
449+
<revision>4.2.0</revision>
450450
<!-- /RELEASE_VERSION -->
451451
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
452452
<java.version>11</java.version>

src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java

+88-86
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public class JavaClientGenerator extends DefaultGenerator implements Generator {
117117
private final Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
118118

119119
protected Stability getStability() {
120-
return Stability.EXPERIMENTAL;
120+
return Stability.STABLE;
121121
}
122122

123123
@Override
@@ -259,87 +259,89 @@ public JavaClientGenerator() {
259259
instantiationTypes.put("null", "Void (null)");
260260

261261
modifyFeatureSet(features -> features
262-
.includeDocumentationFeatures(
263-
DocumentationFeature.Readme,
264-
DocumentationFeature.Servers,
265-
DocumentationFeature.ComponentSchemas,
266-
DocumentationFeature.ComponentSecuritySchemes,
267-
DocumentationFeature.ComponentRequestBodies,
268-
DocumentationFeature.ComponentResponses,
269-
DocumentationFeature.ComponentHeaders,
270-
DocumentationFeature.ComponentParameters
271-
)
272-
.includeGlobalFeatures(
273-
GlobalFeature.Components,
274-
GlobalFeature.Servers,
275-
GlobalFeature.Security,
276-
GlobalFeature.Paths
277-
)
278-
.includeComponentsFeatures(
279-
ComponentsFeature.schemas,
280-
ComponentsFeature.securitySchemes,
281-
ComponentsFeature.requestBodies,
282-
ComponentsFeature.responses,
283-
ComponentsFeature.headers,
284-
ComponentsFeature.parameters
285-
)
286-
.includeSecurityFeatures(
287-
SecurityFeature.ApiKey,
288-
SecurityFeature.HTTP_Basic,
289-
SecurityFeature.HTTP_Bearer
290-
)
291-
.includeOperationFeatures(
292-
OperationFeature.Security,
293-
OperationFeature.Servers,
294-
OperationFeature.Responses_Default,
295-
OperationFeature.Responses_HttpStatusCode,
296-
OperationFeature.Responses_RangedResponseCodes,
297-
OperationFeature.Responses_RedirectionResponse
298-
)
299-
.includeSchemaFeatures(
300-
SchemaFeature.AdditionalProperties,
301-
SchemaFeature.AllOf,
302-
SchemaFeature.AnyOf,
303-
SchemaFeature.Const,
304-
SchemaFeature.Contains,
305-
SchemaFeature.Default,
306-
SchemaFeature.DependentRequired,
307-
SchemaFeature.DependentSchemas,
308-
// SchemaFeature.Discriminator,
309-
SchemaFeature.Else,
310-
SchemaFeature.Enum,
311-
SchemaFeature.ExclusiveMaximum,
312-
SchemaFeature.ExclusiveMinimum,
313-
SchemaFeature.Format,
314-
SchemaFeature.If,
315-
SchemaFeature.Items,
316-
SchemaFeature.MaxContains,
317-
SchemaFeature.MaxItems,
318-
SchemaFeature.MaxLength,
319-
SchemaFeature.MaxProperties,
320-
SchemaFeature.Maximum,
321-
SchemaFeature.MinContains,
322-
SchemaFeature.MinItems,
323-
SchemaFeature.MinLength,
324-
SchemaFeature.MinProperties,
325-
SchemaFeature.Minimum,
326-
SchemaFeature.MultipleOf,
327-
SchemaFeature.Not,
328-
SchemaFeature.Nullable,
329-
SchemaFeature.OneOf,
330-
SchemaFeature.Pattern,
331-
SchemaFeature.PatternProperties,
332-
SchemaFeature.PrefixItems,
333-
SchemaFeature.Properties,
334-
SchemaFeature.PropertyNames,
335-
SchemaFeature.Ref,
336-
SchemaFeature.Required,
337-
SchemaFeature.Then,
338-
SchemaFeature.Type,
339-
SchemaFeature.UnevaluatedItems,
340-
SchemaFeature.UnevaluatedProperties,
341-
SchemaFeature.UniqueItems
342-
)
262+
.includeDocumentationFeatures(
263+
DocumentationFeature.Readme,
264+
DocumentationFeature.Servers,
265+
DocumentationFeature.Security,
266+
DocumentationFeature.ComponentSchemas,
267+
DocumentationFeature.ComponentSecuritySchemes,
268+
DocumentationFeature.ComponentRequestBodies,
269+
DocumentationFeature.ComponentResponses,
270+
DocumentationFeature.ComponentHeaders,
271+
DocumentationFeature.ComponentParameters,
272+
DocumentationFeature.Api
273+
)
274+
.includeGlobalFeatures(
275+
GlobalFeature.Components,
276+
GlobalFeature.Servers,
277+
GlobalFeature.Security,
278+
GlobalFeature.Paths
279+
)
280+
.includeComponentsFeatures(
281+
ComponentsFeature.schemas,
282+
ComponentsFeature.securitySchemes,
283+
ComponentsFeature.requestBodies,
284+
ComponentsFeature.responses,
285+
ComponentsFeature.headers,
286+
ComponentsFeature.parameters
287+
)
288+
.includeSecurityFeatures(
289+
SecurityFeature.ApiKey,
290+
SecurityFeature.HTTP_Basic,
291+
SecurityFeature.HTTP_Bearer
292+
)
293+
.includeOperationFeatures(
294+
OperationFeature.Security,
295+
OperationFeature.Servers,
296+
OperationFeature.Responses_Default,
297+
OperationFeature.Responses_HttpStatusCode,
298+
OperationFeature.Responses_RangedResponseCodes,
299+
OperationFeature.Responses_RedirectionResponse
300+
)
301+
.includeSchemaFeatures(
302+
SchemaFeature.AdditionalProperties,
303+
SchemaFeature.AllOf,
304+
SchemaFeature.AnyOf,
305+
SchemaFeature.Const,
306+
SchemaFeature.Contains,
307+
SchemaFeature.Default,
308+
SchemaFeature.DependentRequired,
309+
SchemaFeature.DependentSchemas,
310+
// SchemaFeature.Discriminator,
311+
SchemaFeature.Else,
312+
SchemaFeature.Enum,
313+
SchemaFeature.ExclusiveMaximum,
314+
SchemaFeature.ExclusiveMinimum,
315+
SchemaFeature.Format,
316+
SchemaFeature.If,
317+
SchemaFeature.Items,
318+
SchemaFeature.MaxContains,
319+
SchemaFeature.MaxItems,
320+
SchemaFeature.MaxLength,
321+
SchemaFeature.MaxProperties,
322+
SchemaFeature.Maximum,
323+
SchemaFeature.MinContains,
324+
SchemaFeature.MinItems,
325+
SchemaFeature.MinLength,
326+
SchemaFeature.MinProperties,
327+
SchemaFeature.Minimum,
328+
SchemaFeature.MultipleOf,
329+
SchemaFeature.Not,
330+
SchemaFeature.Nullable,
331+
SchemaFeature.OneOf,
332+
SchemaFeature.Pattern,
333+
SchemaFeature.PatternProperties,
334+
SchemaFeature.PrefixItems,
335+
SchemaFeature.Properties,
336+
SchemaFeature.PropertyNames,
337+
SchemaFeature.Ref,
338+
SchemaFeature.Required,
339+
SchemaFeature.Then,
340+
SchemaFeature.Type,
341+
SchemaFeature.UnevaluatedItems,
342+
SchemaFeature.UnevaluatedProperties,
343+
SchemaFeature.UniqueItems
344+
)
343345
);
344346

345347
outputFolder = "generated-code" + File.separator + "java";
@@ -378,8 +380,8 @@ public String getHelp() {
378380
"Generates a Java client library",
379381
"",
380382
"Features in this generator:",
381-
"- v3.0.0 - [v3.0.3](#schema-feature) OpenAPI Specification support for component schemas",
382-
"- Very [thorough documentation generated in the style of javadocs, includes code samples](samples/client/petstore/java/docs/components/schemas/Money.md#money)",
383+
"- v3.0.0 - [v3.1.0](#schema-feature) OpenAPI Specification support",
384+
"- Very thorough documentation generated in the style of javadocs",
383385
"- Input types constrained for a Schema in SomeSchema.validate",
384386
" - validate method can accept arbitrary List/Map/null/int/long/double/float/String json data",
385387
"- Immutable List output classes generated and returned by validate for List&lt;?&gt; input",
@@ -403,8 +405,8 @@ public String getHelp() {
403405
"- Generated interfaces are largely consistent with the python code",
404406
"- Openapi spec inline schemas supported at any depth in any location",
405407
"- Format support for: int32, int64, float, double, date, datetime, uuid",
406-
"- Payload values are not coerced when validated, so a datetime value can pass other validations that describe the payload only as type string",
407-
"- types are generated for enums of type string/integer/boolean using typing.Literal",
408+
"- 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",
409+
"- enum types are generated for enums of type string/integer/number/boolean/null",
408410
"- String transmission of numbers supported with type: string, format: number"
409411
);
410412
}

0 commit comments

Comments
 (0)