2929import org .entur .gbfs .validation .model .FileValidationResult ;
3030import org .entur .gbfs .validation .model .ValidationResult ;
3131import org .entur .gbfs .validator .api .gen .ValidateApiDelegate ;
32+ import org .entur .gbfs .validator .api .model .BasicAuth ;
33+ import org .entur .gbfs .validator .api .model .BearerTokenAuth ;
3234import org .entur .gbfs .validator .api .model .FileError ;
3335import org .entur .gbfs .validator .api .model .GbfsFile ;
34- // Import for API SystemError
35- import org .entur .gbfs .validator .api .model .SystemError as ApiSystemError ;
36+ import org . entur . gbfs . validator . api . model . OAuthClientCredentialsGrantAuth ;
37+ import org .entur .gbfs .validator .api .model .SystemError ;
3638import org .entur .gbfs .validator .api .model .ValidatePostRequest ;
3739import org .entur .gbfs .validator .api .model .ValidationResultSummary ;
3840import org .entur .gbfs .validator .loader .LoadedFile ;
3941import org .entur .gbfs .validator .loader .Loader ;
40- import org .entur .gbfs .validator .loader .Authentication ;
41- import org .entur .gbfs .validator .loader .BasicAuth as LoaderBasicAuth ;
42- import org .entur .gbfs .validator .loader .BearerTokenAuth as LoaderBearerTokenAuth ;
43- import org .entur .gbfs .validator .loader .OAuthClientCredentialsGrantAuth as LoaderOAuthClientCredentialsGrantAuth ;
44- import org .entur .gbfs .validator .loader .SystemError as LoaderSystemError ; // Explicitly for loader
45- import org .entur .gbfs .validation .model .SystemError as ValidatorSystemError ; // Explicitly for validator model
42+ import org .entur .gbfs .validator .loader .auth .Authentication ;
43+ import org .entur .gbfs .validator .loader .LoaderError ;
44+ import org .entur .gbfs .validation .model .ValidatorError ;
4645import org .openapitools .jackson .nullable .JsonNullable ;
47- // OpenAPI generated auth models
4846import org .entur .gbfs .validator .api .model .ValidatePostRequestAuth ;
49- import org .entur .gbfs .validator .api .model .BasicAuth ;
50- import org .entur .gbfs .validator .api .model .BearerTokenAuth ;
51- import org .entur .gbfs .validator .api .model .OAuthClientCredentialsGrantAuth ;
5247
5348import org .slf4j .Logger ;
5449import org .slf4j .LoggerFactory ;
@@ -94,24 +89,17 @@ public ResponseEntity<org.entur.gbfs.validator.api.model.ValidationResult> valid
9489 ValidatePostRequestAuth apiAuth = validatePostRequest .getAuth ();
9590
9691 if (apiAuth != null ) {
97- // The OpenAPI generator for 'oneOf' with discriminator typically creates a common wrapper
98- // that holds the actual instance. We need to get that instance.
99- Object actualAuth = apiAuth .getActualInstance (); // This is a common pattern
100-
101- if (actualAuth instanceof BasicAuth ) {
102- BasicAuth basic = (BasicAuth ) actualAuth ;
92+ if (apiAuth instanceof BasicAuth basic ) {
10393 if (basic .getUsername () != null && basic .getPassword () != null ) {
104- loaderAuth = new LoaderBasicAuth (basic .getUsername (), basic .getPassword ());
94+ loaderAuth = new org . entur . gbfs . validator . loader . auth . BasicAuth (basic .getUsername (), basic .getPassword ());
10595 }
106- } else if (actualAuth instanceof BearerTokenAuth ) {
107- BearerTokenAuth bearer = (BearerTokenAuth ) actualAuth ;
96+ } else if (apiAuth instanceof BearerTokenAuth bearer ) {
10897 if (bearer .getToken () != null ) {
109- loaderAuth = new LoaderBearerTokenAuth (bearer .getToken ());
98+ loaderAuth = new org . entur . gbfs . validator . loader . auth . BearerTokenAuth (bearer .getToken ());
11099 }
111- } else if (actualAuth instanceof OAuthClientCredentialsGrantAuth ) {
112- OAuthClientCredentialsGrantAuth oauth = (OAuthClientCredentialsGrantAuth ) actualAuth ;
100+ } else if (apiAuth instanceof OAuthClientCredentialsGrantAuth oauth ) {
113101 if (oauth .getClientId () != null && oauth .getClientSecret () != null && oauth .getTokenUrl () != null ) {
114- loaderAuth = new LoaderOAuthClientCredentialsGrantAuth (oauth .getClientId (), oauth .getClientSecret (), oauth .getTokenUrl ().toString ());
102+ loaderAuth = new org . entur . gbfs . validator . loader . auth . OAuthClientCredentialsGrantAuth (oauth .getClientId (), oauth .getClientSecret (), oauth .getTokenUrl ().toString ());
115103 }
116104 }
117105 }
@@ -245,10 +233,10 @@ private List<GbfsFile> mapFiles(
245233 apiFile .setName (loadedFile .fileName ());
246234 apiFile .setUrl (loadedFile .url ());
247235
248- List <ApiSystemError > combinedApiSystemErrors = new ArrayList <>();
236+ List <SystemError > combinedApiSystemErrors = new ArrayList <>();
249237
250238 // System errors from loader
251- List <LoaderSystemError > loaderSystemErrors = loadedFile .systemErrors ();
239+ List <LoaderError > loaderSystemErrors = loadedFile .loaderErrors ();
252240 if (loaderSystemErrors != null && !loaderSystemErrors .isEmpty ()) {
253241 combinedApiSystemErrors .addAll (mapLoaderSystemErrorsToApi (loaderSystemErrors ));
254242 }
@@ -262,7 +250,7 @@ private List<GbfsFile> mapFiles(
262250 apiFile .setErrors (mapFileValidationErrors (validationResult .errors ()));
263251
264252 // Add system errors from validator (parsing errors)
265- List <ValidatorSystemError > validatorSystemErrors = validationResult .systemErrors ();
253+ List <ValidatorError > validatorSystemErrors = validationResult .validatorErrors ();
266254 if (validatorSystemErrors != null && !validatorSystemErrors .isEmpty ()) {
267255 combinedApiSystemErrors .addAll (mapValidatorSystemErrorsToApi (validatorSystemErrors ));
268256 }
@@ -287,24 +275,24 @@ private List<GbfsFile> mapFiles(
287275 return apiGbfsFiles ;
288276 }
289277
290- private List <ApiSystemError > mapLoaderSystemErrorsToApi (List <LoaderSystemError > loaderSystemErrors ) {
278+ private List <SystemError > mapLoaderSystemErrorsToApi (List <LoaderError > loaderSystemErrors ) {
291279 if (loaderSystemErrors == null ) {
292280 return new ArrayList <>();
293281 }
294282 return loaderSystemErrors .stream ().map (loaderError -> {
295- ApiSystemError apiError = new ApiSystemError ();
283+ SystemError apiError = new SystemError ();
296284 apiError .setError (loaderError .error ());
297285 apiError .setMessage (loaderError .message ());
298286 return apiError ;
299287 }).toList ();
300288 }
301289
302- private List <ApiSystemError > mapValidatorSystemErrorsToApi (List <ValidatorSystemError > validatorSystemErrors ) {
290+ private List <SystemError > mapValidatorSystemErrorsToApi (List <ValidatorError > validatorSystemErrors ) {
303291 if (validatorSystemErrors == null ) {
304292 return new ArrayList <>();
305293 }
306294 return validatorSystemErrors .stream ().map (validatorError -> {
307- ApiSystemError apiError = new ApiSystemError ();
295+ SystemError apiError = new SystemError ();
308296 apiError .setError (validatorError .error ());
309297 apiError .setMessage (validatorError .message ());
310298 return apiError ;
0 commit comments