private Set < ApiResourceMetadata > checkResource ( JCodeModel bodyCodeModel , String baseUrl , RamlResource resource , ApiResourceMetadata controller , RamlRoot document ) { Set < ApiResourceMetadata > controllers = new LinkedHashSet <> ( ) ; // append resource URL to url. String url = baseUrl + resource . getRelativeUri ( ) ; if ( controller == null && shouldCreateController ( resource ) ) { controller = new ApiResourceMetadata ( bodyCodeModel , url , resource , document ) ; controllers . add ( controller ) ; } // extract actions for this resource if ( resource . getActions ( ) != null && ! resource . getActions ( ) . isEmpty ( ) ) { for ( RamlActionType actionType : RamlActionType . values ( ) ) { if ( resource . getActions ( ) . containsKey ( actionType ) ) { RamlAction childResource = resource . getActions ( ) . get ( actionType ) ; // if we have multiple response types in the raml, this // should produce different calls RamlResponse response = null ; if ( childResource . getResponses ( ) != null ) { response = RamlHelper . getSuccessfulResponse ( childResource ) ; } if ( Config . isSeperateMethodsByContentType ( ) && response != null && response . hasBody ( ) && response . getBody ( ) . size ( ) > 1 ) { for ( String responseType : response . getBody ( ) . keySet ( ) ) { controller . addApiCall ( resource , actionType , childResource , responseType ) ; } } else { controller . addApiCall ( resource , actionType , childResource , null ) ; } } } } if ( resource . getResources ( ) != null && ! resource . getResources ( ) . isEmpty ( ) ) { for ( Entry < String , RamlResource > childResource : resource . getResources ( ) . entrySet ( ) ) { controllers . addAll ( checkResource ( bodyCodeModel , url , childResource . getValue ( ) , controller , document ) ) ; } } return controllers ; }
Recursive method to parse resources in a Raml File . It tries to go as deep as possible before creating the root Resource . Once this is done methods and child resources will be relative to the root resource