private Set < String > validatePathAndRetrievePathParams ( ValidationHelper helper , Context context , String pathStr ) { String pathToCheck = pathStr ; Set < String > pathParameters = new HashSet < String > ( ) ; while ( pathToCheck . contains ( "{" ) ) { if ( ! pathToCheck . contains ( "}" ) ) { final String message = Tr . formatMessage ( tc , "pathItemInvalidFormat" , pathStr ) ; helper . addValidationEvent ( new ValidationEvent ( ValidationEvent . Severity . ERROR , context . getLocation ( ) , message ) ) ; return pathParameters ; } int firstIndex = pathToCheck . indexOf ( "{" ) ; int lastIndex = pathToCheck . indexOf ( "}" ) ; if ( firstIndex > lastIndex ) { final String message = Tr . formatMessage ( tc , "pathItemInvalidFormat" , pathStr ) ; helper . addValidationEvent ( new ValidationEvent ( ValidationEvent . Severity . ERROR , context . getLocation ( ) , message ) ) ; return pathParameters ; } String parameter = pathToCheck . substring ( firstIndex + 1 , lastIndex ) ; if ( parameter . isEmpty ( ) || parameter . contains ( "{" ) || parameter . contains ( "/" ) ) { final String message = Tr . formatMessage ( tc , "pathItemInvalidFormat" , pathStr ) ; helper . addValidationEvent ( new ValidationEvent ( ValidationEvent . Severity . ERROR , context . getLocation ( ) , message ) ) ; return pathParameters ; } pathParameters . add ( parameter ) ; pathToCheck = pathToCheck . substring ( lastIndex + 1 ) ; } if ( pathToCheck . contains ( "}" ) ) { final String message = Tr . formatMessage ( tc , "pathItemInvalidFormat" , pathStr ) ; helper . addValidationEvent ( new ValidationEvent ( ValidationEvent . Severity . ERROR , context . getLocation ( ) , message ) ) ; return pathParameters ; } return pathParameters ; }
Validate the path and extract path parameters