src/extension.js
/**
 * Add extra clarity to basic valdation errors that swagger-cli does not provide
 * @param {Object} parsed YAML or JSON parsed
 * @param {Object} doc vscode document object
 */
Add extra clarity to basic valdation errors that swagger-cli does not provide
@param {Object} parsed YAML or JSON parsed
@param {Object} doc vscode document object
Add extra clarity to basic valdation errors that swagger - cli does not provide @param { Object } parsed YAML or JSON parsed @param { Object } doc vscode document object
function preCheck(parsed, doc) {
	const pre = {
		fileName: doc.fileName
	}
	let result = ''
	const regex = /^3\.0\.\d(-.+)?$/
	if (parsed) {
		if (parsed.swagger && parsed.swagger !== "2.0") {
			result+='SyntaxError: Unrecognized Swagger version. Expected 2.0 (also must be String type)\n'
		} else if (parsed.openapi && !regex.test(parsed.openapi)) {
			result+='SyntaxError: Unsupported OpenAPI version. Swagger Parser only supports OpenAPI versions =>3.0.0\n'
		}
		if (!parsed.info) {
			result+='Missing property "info".\n'
		}
		if (!parsed.paths) {
			result+='Missing property "paths".\n'
		}
	}
	pre.message = result
	return pre
}
function preCheck ( parsed , doc ) { const pre = { fileName : doc . fileName } let result = '' const regex = / ^3\.0\.\d(-.+)?$ / if ( parsed ) { if ( parsed . swagger && parsed . swagger !== "2.0" ) { result += 'SyntaxError: Unrecognized Swagger version. Expected 2.0 (also must be String type)\n' } else if ( parsed . openapi && ! regex . test ( parsed . openapi ) ) { result += 'SyntaxError: Unsupported OpenAPI version. Swagger Parser only supports OpenAPI versions =>3.0.0\n' } if ( ! parsed . info ) { result += 'Missing property "info".\n' } if ( ! parsed . paths ) { result += 'Missing property "paths".\n' } } pre . message = result return pre }
Add extra clarity to basic valdation errors that swagger-cli does not provide
 @param {Object} parsed YAML or JSON parsed
 @param {Object} doc vscode document object
Add extra clarity to basic valdation errors that swagger - cli does not provide @param { Object } parsed YAML or JSON parsed @param { Object } doc vscode document object