diff --git a/src/main/java/utils/MappingUtilities.java b/src/main/java/utils/MappingUtilities.java index 09f266f..a74dfe4 100644 --- a/src/main/java/utils/MappingUtilities.java +++ b/src/main/java/utils/MappingUtilities.java @@ -108,22 +108,6 @@ public static JsonSchema setIdNull(JsonSchema schema) { return schema; } - /** - * Generates a JSON schema for the given class, with the option to specify required fields. - * This method uses the Jackson library to generate the schema and customize it based on the provided required fields. - * It sets the ID of the schema and its nested schemas to null and adds the required fields to the schema's "required" property. - * - * @param clazz The class for which the JSON schema should be generated. - * @param requiredFields A varargs array of field names that should be marked as "required" in the schema. - * @return A JsonNode representing the generated schema, or null if an exception occurs during generation. - */ - public static JsonNode getJsonNodeFor(Class clazz, String... requiredFields) { - JsonSchema schema = generateSchema(clazz); - assert schema != null; - schema.setId(null); - return addRequiredFields(schema, requiredFields); - } - /** * Generates a JSON schema for the given class, with the option to specify required fields. * This method uses the Jackson library to generate the schema. @@ -156,32 +140,6 @@ public static JsonSchema generateSchema(Class clazz) { return null; } } - - /** - * Adds the specified required fields to the "required" property of a JSON schema. - * This method adds each field name from the provided array to the "required" property of the schema. - * - * @param schema The JSON schema to modify. - * @param requiredFields An array of field names that should be marked as required in the schema. - * @return - */ - private static JsonNode addRequiredFields(JsonSchema schema, String[] requiredFields) { - JsonNode schemaNode = mapper.valueToTree(schema); - - if (!(schemaNode instanceof ObjectNode root)) { - throw new IllegalArgumentException("Schema must be an ObjectNode"); - } - - ArrayNode required = root.withArray("required"); - - for (String fieldName : requiredFields) { - required.add(fieldName); - } - - // Convert the modified JsonNode back to JsonSchema - return mapper.valueToTree(root); - } - } } }