Skip to content

Commit fec6534

Browse files
committed
Fixed enum for V2
Bumped version
1 parent 9fb4329 commit fec6534

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.20.1] - 2022-02-25
5+
### Fixed
6+
- Support enums with single quotes in names for V2
7+
48
## [0.20.0] - 2022-02-25
59
### Fixed
610
- Updated dependencies
7-
- Support enums with single quotes in names
11+
- Support enums with single quotes in names for V3
812
- Generating better names when `operationId` is not given (breaking change)
913
- Fixed issue where `x-enum` flags where breaking due to non-string values
1014

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openapi-typescript-codegen",
3-
"version": "0.20.0",
3+
"version": "0.20.1",
44
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
55
"author": "Ferdi Koomen",
66
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",

src/openApi/v2/parser/getEnum.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const getEnum = (values?: (string | number)[]): Enum[] => {
2323
.replace(/^(\d+)/g, '_$1')
2424
.replace(/([a-z])([A-Z]+)/g, '$1_$2')
2525
.toUpperCase(),
26-
value: `'${value}'`,
26+
value: `'${value.replace(/'/g, "\\'")}'`,
2727
type: 'string',
2828
description: null,
2929
};

test/__snapshots__/index.spec.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ export enum EnumWithStrings {
10001000
/**
10011001
* null
10021002
*/
1003-
_SINGLE_QUOTE_ = ''Single Quote'',
1003+
_SINGLE_QUOTE_ = '\\\\'Single Quote\\\\'',
10041004
/**
10051005
* null
10061006
*/

0 commit comments

Comments
 (0)