Commit d8fe4719 authored by Martti Käärik's avatar Martti Käärik
Browse files

Check for parse result and throw

parent 12ba17f8
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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.