@sebspark/openapi-typegen 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +14 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -188,10 +188,21 @@ var generateProperty = (property) => {
188
188
  };
189
189
  var preamble = (type) => type.name ? `${document(type)}export type ${typeName(type.name)} = ` : "";
190
190
  var rxProperVariable = /^[a-zA-Z_<>$][a-zA-Z0-9_<>$]*$/;
191
- var typeName = (name) => {
192
- const namingConventionRegex = /^([a-z_]\w*)(<([a-z_]\w*(,\s*)?)+>)?$/;
191
+ var isValidName = (name) => {
192
+ const namingConventionRegex = /^([A-Z_]\w*)([a-z_]\w*)(<([a-z_]\w*(,\s*)?)+>)?$/;
193
193
  const hasCapitalLetterRegex = /[A-Z]/;
194
- if (namingConventionRegex.test(name) && hasCapitalLetterRegex.test(name)) {
194
+ if (!namingConventionRegex.test(name))
195
+ return false;
196
+ if (!hasCapitalLetterRegex.test(name)) {
197
+ return false;
198
+ }
199
+ if (name[0] !== name[0].toUpperCase() && !name.includes("_")) {
200
+ return false;
201
+ }
202
+ return true;
203
+ };
204
+ var typeName = (name) => {
205
+ if (isValidName(name)) {
195
206
  return name;
196
207
  }
197
208
  if (name.includes("<")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sebspark/openapi-typegen",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",