Skip to content

Commit

Permalink
Generated records implement Serializable when serializableModel-c…
Browse files Browse the repository at this point in the history
…onfigOption is enabled (#72)

* Generated records implement `Serializable`

* Update project version 1.6.0 -> 1.6.1
  • Loading branch information
Chrimle authored Sep 19, 2024
1 parent 5c82c41 commit 95896e2
Show file tree
Hide file tree
Showing 72 changed files with 106 additions and 82 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.chrimle</groupId>
<artifactId>openapi-to-java-records-mustache-templates</artifactId>
<version>1.6.0</version>
<version>1.6.1</version>

<name>OpenAPI to Java records :: Mustache Templates</name>
<url>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/licenseInfo.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/
2 changes: 1 addition & 1 deletion src/main/resources/templates/modelEnum.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{!
Source: openapi-to-java-records-mustache-templates
Version: 1.6.0
Version: 1.6.1
Required imports:
- none
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/templates/pojo.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{!
Source: openapi-to-java-records-mustache-templates
Version: 1.6.0
Version: 1.6.1
Required imports:
- none
Expand All @@ -14,7 +14,8 @@
}}{{>javadoc}}{{>deprecation}}{{>additionalModelTypeAnnotations}}{{!
}}public record {{classname}}(
{{#vars}}@{{javaxPackage}}.annotation.{{#isNullable}}Nullable{{/isNullable}}{{^isNullable}}Nonnull{{/isNullable}} {{{datatypeWithEnum}}} {{name}}{{^-last}},
{{/-last}}{{/vars}}) {
{{/-last}}{{/vars}}{{^serializableModel}}){{/serializableModel}}{{#serializableModel}}
) implements Serializable{{/serializableModel}} {
{{>serializableModel}}
public {{classname}}(
{{#vars}}@{{javaxPackage}}.annotation.{{#isNullable}}Nullable{{/isNullable}}{{^isNullable}}{{#defaultValue}}Nullable{{/defaultValue}}{{^defaultValue}}Nonnull{{/defaultValue}}{{/isNullable}} final {{{datatypeWithEnum}}} {{name}}{{^-last}},
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/serializableModel.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{!
Source: openapi-to-java-records-mustache-templates
Version: 1.6.0
Version: 1.6.1
Enabled via configOptions.serializableModel=true
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/com/chrimle/example/utils/AssertionUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.chrimle.example.utils;

import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -198,4 +199,13 @@ private static void assertRecordHasField(
Assertions.assertEquals(fieldType, field.getType());
}

public static void assertClassImplementsSerializable(
final Class<?> classUnderTest,
final boolean isSerializableModel) {

Assertions.assertEquals(
isSerializableModel,
Arrays.asList(classUnderTest.getInterfaces()).contains(Serializable.class)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public static void assertRecord(
isSerializableModel);
AssertionUtils.assertRecordHasFieldsOfType(classUnderTest,
isSerializableModel, fieldClasses);
AssertionUtils.assertClassImplementsSerializable(classUnderTest,
isSerializableModel);
}

public static void assertExampleRecord(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand All @@ -35,7 +35,8 @@
*/
@Deprecated
public record DeprecatedExampleRecord(
@javax.annotation.Nonnull Boolean field1) {
@javax.annotation.Nonnull Boolean field1
) implements Serializable {

private static final long serialVersionUID = 1L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand All @@ -33,7 +33,8 @@
* @param field1 a boolean field
*/
public record ExampleRecord(
@javax.annotation.Nonnull Boolean field1) {
@javax.annotation.Nonnull Boolean field1
) implements Serializable {

private static final long serialVersionUID = 1L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* openapi-to-java-records-mustache-templates. For further information,
* questions, requesting features or reporting issues, please visit:
* https://github.com/Chrimle/openapi-to-java-records-mustache-templates.
* Generated with Version: 1.6.0
* Generated with Version: 1.6.1
*
*/

Expand All @@ -39,7 +39,8 @@
public record ExampleRecordWithArrayFields(
@javax.annotation.Nonnull List<Boolean> field1,
@javax.annotation.Nonnull List<Boolean> field2,
@javax.annotation.Nonnull List<Boolean> field3) {
@javax.annotation.Nonnull List<Boolean> field3
) implements Serializable {

private static final long serialVersionUID = 1L;

Expand Down
Loading

0 comments on commit 95896e2

Please sign in to comment.