Skip to content

Commit

Permalink
fix: serialization type remains string even if the shape is different
Browse files Browse the repository at this point in the history
relates to: #5951

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
  • Loading branch information
shawkins committed May 9, 2024
1 parent 27e0842 commit b295118
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ public abstract class AbstractJsonSchema<T, B> {
new KubernetesSerialization(mapper, false);
GENERATOR = new JsonSchemaGenerator(mapper);

JSON_FORMAT_SHAPE_MAPPING.put(JsonFormat.Shape.BOOLEAN, Types.typeDefFrom(Boolean.class).toReference());
JSON_FORMAT_SHAPE_MAPPING.put(JsonFormat.Shape.NUMBER, Types.typeDefFrom(Double.class).toReference());
JSON_FORMAT_SHAPE_MAPPING.put(JsonFormat.Shape.NUMBER_FLOAT, Types.typeDefFrom(Double.class).toReference());
JSON_FORMAT_SHAPE_MAPPING.put(JsonFormat.Shape.NUMBER_INT, Types.typeDefFrom(Long.class).toReference());
JSON_FORMAT_SHAPE_MAPPING.put(JsonFormat.Shape.STRING, Types.typeDefFrom(String.class).toReference());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ void shouldAugmentPropertiesSchemaFromAnnotations() throws JsonProcessingExcepti
assertEquals(type.apply("string").withDefault(TextNode.valueOf("my-value")).build(), spec.get("defaultValue"));
assertEquals(type.apply("string").withDefault(TextNode.valueOf("my-value2")).build(), spec.get("defaultValue2"));
assertEquals(type.apply("string").withEnum(TextNode.valueOf("non"), TextNode.valueOf("oui")).build(), spec.get("anEnum"));
assertEquals(type.apply("boolean").build(), spec.get("bool"));
assertEquals(type.apply("number").build(), spec.get("num"));
assertEquals(type.apply("number").build(), spec.get("numFloat"));
assertEquals(type.apply("integer").build(), spec.get("numInt"));
assertEquals(type.apply("string").build(), spec.get("bool"));
assertEquals(type.apply("string").build(), spec.get("num"));
assertEquals(type.apply("string").build(), spec.get("numFloat"));
assertEquals(type.apply("string").build(), spec.get("numInt"));
assertEquals(type.apply("string").build(), spec.get("issuedAt"));

// check required list, should register properties with their modified name if needed
Expand Down

0 comments on commit b295118

Please sign in to comment.