From d8fe4719562e2cd8735f44a23d03984926f77ef9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martti=20K=C3=A4=C3=A4rik?= <martti.kaarik@elvior.com>
Date: Tue, 22 Oct 2024 13:27:05 +0300
Subject: [PATCH] Check for parse result and throw

---
 .../mts/tdl/openapi2tdl/next/OpenAPI2TDLTranslatorNext.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/plugins/org.etsi.mts.tdl.openapi2tdl.next/src/org/etsi/mts/tdl/openapi2tdl/next/OpenAPI2TDLTranslatorNext.java b/plugins/org.etsi.mts.tdl.openapi2tdl.next/src/org/etsi/mts/tdl/openapi2tdl/next/OpenAPI2TDLTranslatorNext.java
index 7ab0220c..c9816994 100644
--- a/plugins/org.etsi.mts.tdl.openapi2tdl.next/src/org/etsi/mts/tdl/openapi2tdl/next/OpenAPI2TDLTranslatorNext.java
+++ b/plugins/org.etsi.mts.tdl.openapi2tdl.next/src/org/etsi/mts/tdl/openapi2tdl/next/OpenAPI2TDLTranslatorNext.java
@@ -574,9 +574,13 @@ public class OpenAPI2TDLTranslatorNext extends AbstractTranslator {
 	 *
 	 * @param specFilePath The path to the specification file
 	 * @return A "raw" OpenAPI document
+	 * @throws Exception 
 	 */
-	public static OpenAPI parseSpec(String specFilePath, Boolean processInline) {
+	public static OpenAPI parseSpec(String specFilePath, Boolean processInline) throws Exception {
 		OpenAPI openAPI = new OpenAPIParser().readLocation(specFilePath, null, new ParseOptions()).getOpenAPI();
+		
+		if (openAPI == null)
+			throw new Exception("Failed to parse '" + specFilePath + "', make sure it's valid ");
 		// Invoke helper function to get the original swagger version.
 		// See https://github.com/swagger-api/swagger-parser/pull/1374
 		// Also see https://github.com/swagger-api/swagger-parser/issues/1369.
-- 
GitLab