{"size": 1131, "ext": "js", "max_stars_repo_path": "node_modules/angular-swagger-ui/src/scripts/modules/swagger-yaml-parser.js", "max_stars_repo_name": "galovely/car-notes", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/angular-swagger-ui/src/scripts/modules/swagger-yaml-parser.js", "max_issues_repo_name": "galovely/car-notes", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "node_modules/angular-swagger-ui/src/scripts/modules/swagger-yaml-parser.js", "max_forks_repo_name": "galovely/car-notes", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.5869565217, "max_line_length": 101, "alphanum_fraction": 0.6180371353}
/*
 * Orange angular-swagger-ui - v0.5.5
 *
 * (C) 2015 Orange, all right reserved
 * MIT Licensed
 */
'use strict';

angular
	.module('swaggerUi')
	.service('swaggerUiYamlParser', function($window, $q, swaggerModules, swaggerTranslator) {

		/**
		 * Module entry point
		 */
		this.execute = function(data) {
			var deferred = $q.defer();
			if (data.parser === 'yaml' || (data.parser === 'auto' && data.contentType.indexOf('/yaml') > 0)) {
				var YAML = $window.jsyaml;
				if (typeof YAML === 'undefined') {
					deferred.reject({
						code: 500,
						message: swaggerTranslator.translate('errorNoYamlParser')
					});
				} else {
					try {
						data.openApiSpec = YAML.load(data.openApiSpec);
						data.parser = 'json';
						deferred.resolve(true);
					} catch (e) {
						deferred.reject({
							code: 500,
							message: swaggerTranslator.translate('errorParseFailed', e)
						});
					}
				}
			} else {
				deferred.resolve(false);
			}
			return deferred.promise;
		};

	})
	.run(function(swaggerModules, swaggerUiYamlParser) {
		swaggerModules.add(swaggerModules.BEFORE_PARSE, swaggerUiYamlParser, 20);
	});