Skip to content

Commit 2891105

Browse files
committed
getType: fix case for model names containing only numbers
1 parent 1e33b1f commit 2891105

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/openApi/v3/parser/getType.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { getMappedType } from './getMappedType';
44
import { stripNamespace } from './stripNamespace';
55

66
const encode = (value: string): string => {
7-
return value.replace(/^[^a-zA-Z_$]+/g, '').replace(/[^\w$]+/g, '_');
7+
const res = value.replace(/^[^a-zA-Z_$]+/g, '').replace(/[^\w$]+/g, '_');
8+
// for model names only containing number (e.g. 401), we have the fallback here:
9+
return res || `_${value.replace(/^[^a-zA-Z0-9_$]+/g, '').replace(/[^\w$]+/g, '_')}`;
810
};
911

1012
/**

0 commit comments

Comments
 (0)