Skip to content

Commit

Permalink
Seal interfaces by default
Browse files Browse the repository at this point in the history
  • Loading branch information
sschnabe committed Aug 24, 2023
1 parent 8fd8350 commit f3c0ba1
Show file tree
Hide file tree
Showing 110 changed files with 2,644 additions and 75 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Include in your `pom.xml`:
* pagable: generate provider for pagable (default `false`)
* generateExamples: generate example objects for the model, based on example and default values (default `false`)
* generateAuthentication: generate Àuthentication into controller interfaces if response code 401 is present (default `false`)
* sealed: generate sealed interfaces (default `true`)

For examples see [integration tests](src/it).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = PropertyTypeOne.class),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = PropertyTypeTwo.class)
})
public interface AdditionalPropertiesModelValue {}
public sealed interface AdditionalPropertiesModelValue permits PropertyTypeOne, PropertyTypeTwo {}
2 changes: 1 addition & 1 deletion gen/main/java/testmodel/micronaut_pojo/FirstModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class FirstModel implements OneOfModel {
public final class FirstModel implements OneOfModel {

public static final java.lang.String JSON_PROPERTY_TYPE = "type";
public static final java.lang.String JSON_PROPERTY_FIRST = "first";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceExtended implements InheritanceSimple {
public final class InheritanceExtended implements InheritanceSimple {

public static final java.lang.String JSON_PROPERTY_BAR = "bar";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@com.fasterxml.jackson.databind.annotation.JsonDeserialize(as = InheritanceSimpleDefault.class)
public interface InheritanceSimple {
public sealed interface InheritanceSimple permits InheritanceExtended, InheritanceSimpleDefault {

java.lang.String JSON_PROPERTY_FOO = "foo";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceSimpleDefault implements InheritanceSimple {
public final class InheritanceSimpleDefault implements InheritanceSimple {

@jakarta.validation.constraints.NotNull
@com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_FOO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithEnumType2.class, name = "Inheritance2"),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithEnumType3.class, name = "Inheritance3")
})
public interface InheritanceWithEnumType {
public sealed interface InheritanceWithEnumType permits InheritanceWithEnumType1, InheritanceWithEnumType2, InheritanceWithEnumType3 {

java.lang.String JSON_DISCRIMINATOR = "type";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithEnumType1 implements InheritanceWithEnumType {
public final class InheritanceWithEnumType1 implements InheritanceWithEnumType {

public static final java.lang.String JSON_PROPERTY_D = "d";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithEnumType2 implements InheritanceWithEnumType {
public final class InheritanceWithEnumType2 implements InheritanceWithEnumType {

public static final java.lang.String JSON_PROPERTY_E = "e";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithEnumType3 implements InheritanceWithEnumType {
public final class InheritanceWithEnumType3 implements InheritanceWithEnumType {

@Override
public InheritanceWithEnumTypeEnum getType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithStringType1.class, name = "Inheritance1"),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithStringType2.class, name = "Inheritance2")
})
public interface InheritanceWithStringType {
public sealed interface InheritanceWithStringType permits InheritanceWithStringType1, InheritanceWithStringType2 {

java.lang.String JSON_DISCRIMINATOR = "type";
java.lang.String JSON_PROPERTY_A = "a";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithStringType1 implements InheritanceWithStringType {
public final class InheritanceWithStringType1 implements InheritanceWithStringType {

public static final java.lang.String JSON_PROPERTY_B = "b";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithStringType2 implements InheritanceWithStringType {
public final class InheritanceWithStringType2 implements InheritanceWithStringType {

public static final java.lang.String JSON_PROPERTY_C = "c";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithoutType1.class, name = "Inheritance1"),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithoutType2.class, name = "Inheritance2")
})
public interface InheritanceWithoutType {
public sealed interface InheritanceWithoutType permits InheritanceWithoutType1, InheritanceWithoutType2 {

java.lang.String JSON_DISCRIMINATOR = "type";
java.lang.String JSON_PROPERTY_E = "e";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithoutType1 implements InheritanceWithoutType {
public final class InheritanceWithoutType1 implements InheritanceWithoutType {

public static final java.lang.String JSON_PROPERTY_F = "f";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithoutType2 implements InheritanceWithoutType {
public final class InheritanceWithoutType2 implements InheritanceWithoutType {

public static final java.lang.String JSON_PROPERTY_G = "g";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class OneOfImplementor1 implements OneOfInterface {
public final class OneOfImplementor1 implements OneOfInterface {

public static final java.lang.String JSON_PROPERTY_PROPERTY = "property";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class OneOfImplementor2 implements OneOfInterface {
public final class OneOfImplementor2 implements OneOfInterface {

public static final java.lang.String JSON_PROPERTY_PROPERTY = "property";

Expand Down
2 changes: 1 addition & 1 deletion gen/main/java/testmodel/micronaut_pojo/OneOfInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = OneOfImplementor1.class, name = "Implementation1"),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = OneOfImplementor2.class, name = "Implementation2"),
})
public interface OneOfInterface {
public sealed interface OneOfInterface permits OneOfImplementor1, OneOfImplementor2 {

java.lang.String JSON_DISCRIMINATOR = "type";

Expand Down
2 changes: 1 addition & 1 deletion gen/main/java/testmodel/micronaut_pojo/OneOfModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = FirstModel.class),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = SecondLevelModel.class)
})
public interface OneOfModel {}
public sealed interface OneOfModel permits FirstModel, SecondLevelModel {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class PropertyTypeOne implements AdditionalPropertiesModelValue {
public final class PropertyTypeOne implements AdditionalPropertiesModelValue {

public static final java.lang.String JSON_PROPERTY_TYPE = "type";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class PropertyTypeTwo implements AdditionalPropertiesModelValue {
public final class PropertyTypeTwo implements AdditionalPropertiesModelValue {

public static final java.lang.String JSON_PROPERTY_TYPE = "type";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = SecondLevelOneModel.class),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = SecondLevelTwoModel.class)
})
public interface SecondLevelModel extends OneOfModel {}
public sealed interface SecondLevelModel extends OneOfModel permits SecondLevelOneModel, SecondLevelTwoModel {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class SecondLevelOneModel implements SecondLevelModel {
public final class SecondLevelOneModel implements SecondLevelModel {

public static final java.lang.String JSON_PROPERTY_TYPE = "type";
public static final java.lang.String JSON_PROPERTY_ONE = "one";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class SecondLevelTwoModel implements SecondLevelModel {
public final class SecondLevelTwoModel implements SecondLevelModel {

public static final java.lang.String JSON_PROPERTY_TYPE = "type";
public static final java.lang.String JSON_PROPERTY_TWO = "two";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = PropertyTypeOne.class),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = PropertyTypeTwo.class)
})
public interface AdditionalPropertiesModelValue {}
public sealed interface AdditionalPropertiesModelValue permits PropertyTypeOne, PropertyTypeTwo {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class FirstModel implements OneOfModel {
public final class FirstModel implements OneOfModel {

public static final java.lang.String JSON_PROPERTY_TYPE = "type";
public static final java.lang.String JSON_PROPERTY_FIRST = "first";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceExtended implements InheritanceSimple {
public final class InheritanceExtended implements InheritanceSimple {

public static final java.lang.String JSON_PROPERTY_BAR = "bar";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@com.fasterxml.jackson.databind.annotation.JsonDeserialize(as = InheritanceSimpleDefault.class)
public interface InheritanceSimple {
public sealed interface InheritanceSimple permits InheritanceExtended, InheritanceSimpleDefault {

java.lang.String JSON_PROPERTY_FOO = "foo";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceSimpleDefault implements InheritanceSimple {
public final class InheritanceSimpleDefault implements InheritanceSimple {

@jakarta.validation.constraints.NotNull
@com.fasterxml.jackson.annotation.JsonProperty(JSON_PROPERTY_FOO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithEnumType2.class, name = "Inheritance2"),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithEnumType3.class, name = "Inheritance3")
})
public interface InheritanceWithEnumType {
public sealed interface InheritanceWithEnumType permits InheritanceWithEnumType1, InheritanceWithEnumType2, InheritanceWithEnumType3 {

java.lang.String JSON_DISCRIMINATOR = "type";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithEnumType1 implements InheritanceWithEnumType {
public final class InheritanceWithEnumType1 implements InheritanceWithEnumType {

public static final java.lang.String JSON_PROPERTY_D = "d";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithEnumType2 implements InheritanceWithEnumType {
public final class InheritanceWithEnumType2 implements InheritanceWithEnumType {

public static final java.lang.String JSON_PROPERTY_E = "e";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithEnumType3 implements InheritanceWithEnumType {
public final class InheritanceWithEnumType3 implements InheritanceWithEnumType {

@Override
public InheritanceWithEnumTypeEnum getType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithStringType1.class, name = "Inheritance1"),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithStringType2.class, name = "Inheritance2")
})
public interface InheritanceWithStringType {
public sealed interface InheritanceWithStringType permits InheritanceWithStringType1, InheritanceWithStringType2 {

java.lang.String JSON_DISCRIMINATOR = "type";
java.lang.String JSON_PROPERTY_A = "a";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithStringType1 implements InheritanceWithStringType {
public final class InheritanceWithStringType1 implements InheritanceWithStringType {

public static final java.lang.String JSON_PROPERTY_B = "b";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithStringType2 implements InheritanceWithStringType {
public final class InheritanceWithStringType2 implements InheritanceWithStringType {

public static final java.lang.String JSON_PROPERTY_C = "c";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithoutType1.class, name = "Inheritance1"),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = InheritanceWithoutType2.class, name = "Inheritance2")
})
public interface InheritanceWithoutType {
public sealed interface InheritanceWithoutType permits InheritanceWithoutType1, InheritanceWithoutType2 {

java.lang.String JSON_DISCRIMINATOR = "type";
java.lang.String JSON_PROPERTY_E = "e";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithoutType1 implements InheritanceWithoutType {
public final class InheritanceWithoutType1 implements InheritanceWithoutType {

public static final java.lang.String JSON_PROPERTY_F = "f";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class InheritanceWithoutType2 implements InheritanceWithoutType {
public final class InheritanceWithoutType2 implements InheritanceWithoutType {

public static final java.lang.String JSON_PROPERTY_G = "g";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class OneOfImplementor1 implements OneOfInterface {
public final class OneOfImplementor1 implements OneOfInterface {

public static final java.lang.String JSON_PROPERTY_PROPERTY = "property";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class OneOfImplementor2 implements OneOfInterface {
public final class OneOfImplementor2 implements OneOfInterface {

public static final java.lang.String JSON_PROPERTY_PROPERTY = "property";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = OneOfImplementor1.class, name = "Implementation1"),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = OneOfImplementor2.class, name = "Implementation2"),
})
public interface OneOfInterface {
public sealed interface OneOfInterface permits OneOfImplementor1, OneOfImplementor2 {

java.lang.String JSON_DISCRIMINATOR = "type";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = FirstModel.class),
@com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = SecondLevelModel.class)
})
public interface OneOfModel {}
public sealed interface OneOfModel permits FirstModel, SecondLevelModel {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class PropertyTypeOne implements AdditionalPropertiesModelValue {
public final class PropertyTypeOne implements AdditionalPropertiesModelValue {

public static final java.lang.String JSON_PROPERTY_TYPE = "type";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@jakarta.annotation.Generated("org.openapitools.codegen.languages.MicronautCodegen")
@io.micronaut.serde.annotation.Serdeable
public class PropertyTypeTwo implements AdditionalPropertiesModelValue {
public final class PropertyTypeTwo implements AdditionalPropertiesModelValue {

public static final java.lang.String JSON_PROPERTY_TYPE = "type";

Expand Down
Loading

0 comments on commit f3c0ba1

Please sign in to comment.