Skip to content

Commit

Permalink
Adding the changelog entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio Burzigotti committed Sep 8, 2022
1 parent d16ea6b commit 6058508
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 233 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#### Improvements
* Fix #4348: Introduce specific annotations for the generators
* Fix #4384: The Java generator now supports the generation of specific annotations (min, max, pattern, etc.), as defined by #4348

#### Dependency Upgrade
* Fix #4243: Update Tekton pipeline model to v0.39.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected String getClassType() {
}

protected AbstractJSONSchema2Pojo(Config config, String description, final boolean isNullable, JsonNode defaultValue,
final Optional<ValidationProperties> validationProperties) {
final Optional<ValidationProperties> validationProperties) {
this.config = config;
this.description = description;
this.isNullable = isNullable;
Expand Down Expand Up @@ -204,16 +204,16 @@ private static AbstractJSONSchema2Pojo fromJsonSchema(
switch (nt.getType()) {
case PRIMITIVE:
return new JPrimitive(
nt.getName(),
config,
prop.getDescription(),
isNullable,
prop.getDefault(),
Optional.of(ValidationProperties.Builder.getInstance()
.withMaximum(prop.getMaximum())
.withMinimum(prop.getMinimum())
.withPattern(prop.getPattern())
.build()));
nt.getName(),
config,
prop.getDescription(),
isNullable,
prop.getDefault(),
Optional.of(ValidationProperties.Builder.getInstance()
.withMaximum(prop.getMaximum())
.withMinimum(prop.getMinimum())
.withPattern(prop.getPattern())
.build()));
case ARRAY:
return new JArray(
fromJsonSchema(
Expand All @@ -226,8 +226,7 @@ private static AbstractJSONSchema2Pojo fromJsonSchema(
config,
prop.getDescription(),
isNullable,
prop.getDefault()
);
prop.getDefault());
case MAP:
return new JMap(
fromJsonSchema(
Expand All @@ -240,8 +239,7 @@ private static AbstractJSONSchema2Pojo fromJsonSchema(
config,
prop.getDescription(),
isNullable,
prop.getDefault()
);
prop.getDefault());
case OBJECT:
final boolean preserveUnknownFields = Boolean.TRUE.equals(prop.getXKubernetesPreserveUnknownFields());
return new JObject(
Expand All @@ -255,17 +253,15 @@ private static AbstractJSONSchema2Pojo fromJsonSchema(
config,
prop.getDescription(),
isNullable,
prop.getDefault()
);
prop.getDefault());
case ENUM:
return new JEnum(
key,
prop.getEnum(),
config,
prop.getDescription(),
isNullable,
prop.getDefault()
);
key,
prop.getEnum(),
config,
prop.getDescription(),
isNullable,
prop.getDefault());
default:
throw new JavaGeneratorException("Unreachable " + nt.getType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,24 +201,21 @@ public GeneratorResult generateJava() {
}
if (prop.getMaximum() != null) {
objField.addAnnotation(
new SingleMemberAnnotationExpr(
new Name("io.fabric8.generator.annotation.Max"),
new DoubleLiteralExpr(prop.getMaximum()))
);
new SingleMemberAnnotationExpr(
new Name("io.fabric8.generator.annotation.Max"),
new DoubleLiteralExpr(prop.getMaximum())));
}
if (prop.getMinimum() != null) {
objField.addAnnotation(
new SingleMemberAnnotationExpr(
new Name("io.fabric8.generator.annotation.Min"),
new DoubleLiteralExpr(prop.getMinimum()))
);
new SingleMemberAnnotationExpr(
new Name("io.fabric8.generator.annotation.Min"),
new DoubleLiteralExpr(prop.getMinimum())));
}
if (prop.getPattern() != null) {
objField.addAnnotation(
new SingleMemberAnnotationExpr(
new Name("io.fabric8.generator.annotation.Pattern"),
new StringLiteralExpr(StringEscapeUtils.escapeJava(prop.getPattern())))
);
new SingleMemberAnnotationExpr(
new Name("io.fabric8.generator.annotation.Pattern"),
new StringLiteralExpr(StringEscapeUtils.escapeJava(prop.getPattern()))));
}

objField.createGetter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class JPrimitive extends AbstractJSONSchema2Pojo {
private static final GeneratorResult empty = new GeneratorResult(new ArrayList<>(), new ArrayList<>());

public JPrimitive(String type, Config config, String description, final boolean isNullable, JsonNode defaultValue,
final Optional<ValidationProperties> validationProperties) {
final Optional<ValidationProperties> validationProperties) {
super(config, description, isNullable, defaultValue, validationProperties);
this.type = type;
}
Expand Down

0 comments on commit 6058508

Please sign in to comment.