@@ -23,23 +23,29 @@ public class InputSchemaService {
2323 * Extracts all unique input paths from all benefits in a screener.
2424 *
2525 * @param benefits List of benefits containing checks with inputDefinitions
26- * @return Set of unique dot-separated paths (e.g., "people.applicant.dateOfBirth")
26+ * @return List of unique FormPath objects
2727 */
28- public Set <FormPath > extractAllInputPaths (List <Benefit > benefits ) {
29- Set < FormPath > pathSet = new HashSet <>();
28+ public List <FormPath > extractUniqueInputPaths (List <Benefit > benefits ) {
29+ Map < String , String > pathTypeMap = new HashMap <>();
3030
3131 for (Benefit benefit : benefits ) {
3232 List <CheckConfig > checks = benefit .getChecks ();
3333 if (checks == null ) continue ;
3434
3535 for (CheckConfig check : checks ) {
3636 JsonNode transformedSchema = transformInputDefinitionSchema (check );
37- List <FormPath > paths = extractJsonSchemaPaths (transformedSchema );
38- pathSet .addAll (paths );
37+ List <FormPath > checkFormPaths = extractJsonSchemaPaths (transformedSchema );
38+ for (FormPath checkFormPath : checkFormPaths ) {
39+ // If the same path exists with different types, keep the first one found
40+ pathTypeMap .putIfAbsent (checkFormPath .getPath (), checkFormPath .getType ());
41+ }
3942 }
4043 }
4144
42- return pathSet ;
45+ // Convert to sorted list of FormPath objects
46+ return pathTypeMap .entrySet ().stream ()
47+ .map (entry -> new FormPath (entry .getKey (), entry .getValue ()))
48+ .toList ();
4349 }
4450
4551 /**
0 commit comments