Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/error on single quote enum #19

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bin/generators/codecGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ var splitRequiredAndOptional = utils_1.reduce(function (_a, _b) {
? [__spreadArrays(required, [property]), optional]
: [required, __spreadArrays(optional, [property])];
}, [[], []]);
var safeSurroundEnum = function (item) {
if (item.indexOf("'") !== -1) {
return utils_1.surround('t.literal("', '")')(item);
}
return utils_1.surround("t.literal('", "')")(item);
};
exports.codecGenerator = {
getTypeString: function () { return "t.string"; },
getTypeNumber: function () { return "t.number"; },
getTypeInteger: function () { return "t.number"; },
getTypeBoolean: function () { return "t.boolean"; },
getTypeEnum: function_1.flow(utils_1.map(utils_1.surround("t.literal('", "')")), getUnion),
getTypeEnum: function_1.flow(utils_1.map(safeSurroundEnum), getUnion),
getTypeArray: utils_1.surround("t.array(", ")"),
getTypeAnyOf: getUnion,
getTypeOneOf: getUnion,
Expand Down
8 changes: 7 additions & 1 deletion bin/generators/flowGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ exports.flowGenerator = void 0;
var function_1 = require("fp-ts/lib/function");
var pipeable_1 = require("fp-ts/lib/pipeable");
var utils_1 = require("../services/utils");
var safeSurroundEnum = function (item) {
if (item.indexOf("'") !== -1) {
return utils_1.surround('"', '"')(item);
}
return utils_1.surround("'", "'")(item);
};
exports.flowGenerator = {
getTypeString: function () { return "string"; },
getTypeNumber: function () { return "number"; },
getTypeInteger: function () { return "number"; },
getTypeBoolean: function () { return "boolean"; },
getTypeEnum: function_1.flow(utils_1.map(utils_1.surround("'", "'")), utils_1.join("|")),
getTypeEnum: function_1.flow(utils_1.map(safeSurroundEnum), utils_1.join("|")),
getTypeArray: utils_1.surround("Array<", ">"),
getTypeAnyOf: utils_1.join("|"),
getTypeOneOf: utils_1.join("|"),
Expand Down
8 changes: 7 additions & 1 deletion bin/generators/typescriptGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ exports.typeScriptGenerator = void 0;
var function_1 = require("fp-ts/lib/function");
var pipeable_1 = require("fp-ts/lib/pipeable");
var utils_1 = require("../services/utils");
var safeSurroundEnum = function (item) {
if (item.indexOf("'") !== -1) {
return utils_1.surround('"', '"')(item);
}
return utils_1.surround("'", "'")(item);
};
exports.typeScriptGenerator = {
getTypeString: function () { return "string"; },
getTypeNumber: function () { return "number"; },
getTypeInteger: function () { return "number"; },
getTypeBoolean: function () { return "boolean"; },
getTypeEnum: function_1.flow(utils_1.map(utils_1.surround("'", "'")), utils_1.join("|")),
getTypeEnum: function_1.flow(utils_1.map(safeSurroundEnum), utils_1.join("|")),
getTypeArray: utils_1.surround("Array<", ">"),
getTypeAnyOf: utils_1.join("|"),
getTypeOneOf: utils_1.join("|"),
Expand Down
8 changes: 7 additions & 1 deletion dist/generators/codecGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ var splitRequiredAndOptional = utils_1.reduce(function (_a, _b) {
? [__spreadArrays(required, [property]), optional]
: [required, __spreadArrays(optional, [property])];
}, [[], []]);
var safeSurroundEnum = function (item) {
if (item.indexOf("'") !== -1) {
return utils_1.surround('t.literal("', '")')(item);
}
return utils_1.surround("t.literal('", "')")(item);
};
exports.codecGenerator = {
getTypeString: function () { return "t.string"; },
getTypeNumber: function () { return "t.number"; },
getTypeInteger: function () { return "t.number"; },
getTypeBoolean: function () { return "t.boolean"; },
getTypeEnum: function_1.flow(utils_1.map(utils_1.surround("t.literal('", "')")), getUnion),
getTypeEnum: function_1.flow(utils_1.map(safeSurroundEnum), getUnion),
getTypeArray: utils_1.surround("t.array(", ")"),
getTypeAnyOf: getUnion,
getTypeOneOf: getUnion,
Expand Down
8 changes: 7 additions & 1 deletion dist/generators/flowGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ exports.flowGenerator = void 0;
var function_1 = require("fp-ts/lib/function");
var pipeable_1 = require("fp-ts/lib/pipeable");
var utils_1 = require("../services/utils");
var safeSurroundEnum = function (item) {
if (item.indexOf("'") !== -1) {
return utils_1.surround('"', '"')(item);
}
return utils_1.surround("'", "'")(item);
};
exports.flowGenerator = {
getTypeString: function () { return "string"; },
getTypeNumber: function () { return "number"; },
getTypeInteger: function () { return "number"; },
getTypeBoolean: function () { return "boolean"; },
getTypeEnum: function_1.flow(utils_1.map(utils_1.surround("'", "'")), utils_1.join("|")),
getTypeEnum: function_1.flow(utils_1.map(safeSurroundEnum), utils_1.join("|")),
getTypeArray: utils_1.surround("Array<", ">"),
getTypeAnyOf: utils_1.join("|"),
getTypeOneOf: utils_1.join("|"),
Expand Down
8 changes: 7 additions & 1 deletion dist/generators/typescriptGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ exports.typeScriptGenerator = void 0;
var function_1 = require("fp-ts/lib/function");
var pipeable_1 = require("fp-ts/lib/pipeable");
var utils_1 = require("../services/utils");
var safeSurroundEnum = function (item) {
if (item.indexOf("'") !== -1) {
return utils_1.surround('"', '"')(item);
}
return utils_1.surround("'", "'")(item);
};
exports.typeScriptGenerator = {
getTypeString: function () { return "string"; },
getTypeNumber: function () { return "number"; },
getTypeInteger: function () { return "number"; },
getTypeBoolean: function () { return "boolean"; },
getTypeEnum: function_1.flow(utils_1.map(utils_1.surround("'", "'")), utils_1.join("|")),
getTypeEnum: function_1.flow(utils_1.map(safeSurroundEnum), utils_1.join("|")),
getTypeArray: utils_1.surround("Array<", ">"),
getTypeAnyOf: utils_1.join("|"),
getTypeOneOf: utils_1.join("|"),
Expand Down
Loading