Skip to content

Commit

Permalink
fix(core): use pattern inseatd of format in the JSON Schema
Browse files Browse the repository at this point in the history
Fixes #6037
  • Loading branch information
loicmathieu authored and tchiotludo committed Nov 22, 2024
1 parent 300d986 commit c50a3b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ public CustomDefinition provideCustomSchemaDefinition(ResolvedType javaType, Sch

if (member.getDeclaredType().isInstanceOf(Property.class)) {
memberAttributes.put("$dynamic", true);
// if we are in the String definition of a Property but the target type is not String: we configure the format
// if we are in the String definition of a Property but the target type is not String: we configure the pattern
Class<?> targetType = member.getDeclaredType().getTypeParameters().getFirst().getErasedType();
if (!String.class.isAssignableFrom(targetType) && String.class.isAssignableFrom(member.getType().getErasedType())) {
memberAttributes.put("format", ".*{{.*}}.*");
memberAttributes.put("pattern", ".*{{.*}}.*");
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void dynamicProperty() throws URISyntaxException {
assertThat(oneOf.getFirst().get("type"), is("integer"));
assertThat(oneOf.getFirst().get("$dynamic"), is(true));
assertThat(oneOf.get(1).get("type"), is("string"));
assertThat(oneOf.get(1).get("format"), is(".*{{.*}}.*"));
assertThat(oneOf.get(1).get("pattern"), is(".*{{.*}}.*"));

Map<String, Object> withDefault = (Map<String, Object>) properties.get("withDefault");
assertThat(withDefault.get("type"), is("string"));
Expand Down

0 comments on commit c50a3b4

Please sign in to comment.