"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("../../commons/utils/utils");
var config_1 = require("../../configs/config");
var schemaUtil_1 = require("../../commons/utils/schemaUtil");
/**
* Class which holds the logic for generating raml types.
*
* @export
* @class RamlContentGenerator
*/
var RamlContentGenerator = (function () {
function RamlContentGenerator() {
}
/**
* Generate type file content.
*
* @param {Table} table - table schema
* @return {string} raml content
*/
RamlContentGenerator.prototype.generateTypeContent = function (table) {
var objectContent = '#%RAML 1.0 DataType\ntype: object\nproperties:\n';
table.columns.forEach(function (column) {
objectContent += utils_1.default.formatLine(config_1.default.DEFAULT_INDENTATION, 0, column.name + ":");
objectContent += utils_1.default.formatLine(config_1.default.DEFAULT_INDENTATION, 1, "required: " + (column.allowNull ? 'false' : 'true'));
var typeLine = column.dataType.values ? schemaUtil_1.default.valuesToRamlDataType(column.dataType.values) :
"" + column.dataType.type + (column.dataType.isArray ? '[]' : '');
objectContent += utils_1.default.formatLine(config_1.default.DEFAULT_INDENTATION, 1, "type: " + typeLine);
});
return objectContent;
};
return RamlContentGenerator;
}());
exports.RamlContentGenerator = RamlContentGenerator;
exports.default = new RamlContentGenerator();
|