From f756f39288e524e4b0c0dc76f26f0ef290975394 Mon Sep 17 00:00:00 2001 From: Jan Michael VIncent Trinidad Date: Wed, 16 Dec 2020 20:14:47 +0400 Subject: [PATCH 1/2] feat: prefer const assertion instead of enum when converting Enums from swagger --- lib/typescript-fetch/modelEnum.mustache | 8 +++++--- lib/typescript-fetch/modelGeneric.mustache | 14 ++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/typescript-fetch/modelEnum.mustache b/lib/typescript-fetch/modelEnum.mustache index afd34ea..23b5951 100644 --- a/lib/typescript-fetch/modelEnum.mustache +++ b/lib/typescript-fetch/modelEnum.mustache @@ -3,10 +3,12 @@ * @export * @enum {string} */ -export enum {{classname}} { +export const {{classname}} = { {{#allowableValues}} {{#enumVars}} - {{{name}}} = {{{value}}}{{^@last}},{{/@last}} + {{{name}}}:{{{value}}}{{^@last}},{{/@last}} {{/enumVars}} {{/allowableValues}} -} +} as const + +export type {{classname}} = typeof {{classname}}[keyof typeof {{classname}}] diff --git a/lib/typescript-fetch/modelGeneric.mustache b/lib/typescript-fetch/modelGeneric.mustache index 940602e..c6a3782 100644 --- a/lib/typescript-fetch/modelGeneric.mustache +++ b/lib/typescript-fetch/modelGeneric.mustache @@ -26,16 +26,18 @@ export namespace {{classname}} { {{#vars}} {{#isEnum}} /** - * @export - * @enum {string} - */ - export enum {{enumName}} { + * {{{description}}} + * @export + */ + export const {{enumName}} = { {{#allowableValues}} {{#enumVars}} - {{{name}}} = {{{value}}}{{^@last}},{{/@last}} + {{{name}}}: {{{value}}}{{^@last}},{{/@last}} {{/enumVars}} {{/allowableValues}} - } + } as const + + export type {{enumName}} = typeof {{enumName}}[keyof typeof {{enumName}}] {{/isEnum}} {{/vars}} }{{/hasEnums}} From 70d618ea414b335cd2edc8ef5c4f9054573df784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Gandecki?= <4002543+lgandecki@users.noreply.github.com> Date: Thu, 17 Dec 2020 07:59:48 +0100 Subject: [PATCH 2/2] fix(release): backward incompatible version bump BREAKING CHANGE: consts instead of enums --- manual-releases.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 manual-releases.md diff --git a/manual-releases.md b/manual-releases.md new file mode 100644 index 0000000..154fc8a --- /dev/null +++ b/manual-releases.md @@ -0,0 +1,44 @@ +# manual-releases + +This project has an automated release set up. So things are only released when +there are useful changes in the code that justify a release. But sometimes +things get messed up one way or another and we need to trigger the release +ourselves. When this happens, simply bump the number below and commit that with +the following commit message based on your needs: + +**Major** + +``` +fix(release): manually release a major version + +There was an issue with a major release, so this manual-releases.md +change is to release a new major version. + +Reference: # + +BREAKING CHANGE: +``` + +**Minor** + +``` +feat(release): manually release a minor version + +There was an issue with a minor release, so this manual-releases.md +change is to release a new minor version. + +Reference: # +``` + +**Patch** + +``` +fix(release): manually release a patch version + +There was an issue with a patch release, so this manual-releases.md +change is to release a new patch version. + +Reference: # +``` + +The number of times we've had to do a manual release is: 1