swaggie 1.3.0-test.2 → 1.3.0-test.3

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.
@@ -46,11 +46,16 @@ function renderSchema(
46
46
  options
47
47
  ) {
48
48
  const safeName = _swagger.getSafeIdentifier.call(void 0, name);
49
+ if (!safeName) {
50
+ console.warn(`Skipping schema ${name} because it is not a valid identifier`);
51
+ return '';
52
+ }
49
53
 
50
54
  // This is an interesting case, because it is allowed but not likely to be used
51
55
  // as it is just a reference to another schema object
52
56
  if ('$ref' in schema) {
53
- return `export type ${safeName} = ${_swagger.getSafeIdentifier.call(void 0, schema.$ref.split('/').pop())};`;
57
+ const refName = _swagger.getSafeIdentifier.call(void 0, schema.$ref.split('/').pop());
58
+ return `export type ${safeName} = ${refName || 'unknown'};`;
54
59
  }
55
60
 
56
61
  const result = [];
@@ -55,7 +55,7 @@ function findDirectRefs(obj, options, refs) {
55
55
 
56
56
  // If the object is deprecated and we want to skip deprecated objects,
57
57
  // we won't process it and anything below it
58
- if (options.skipDeprecated && 'deprecated' in obj && obj.deprecated) {
58
+ if (options.skipDeprecated && obj.deprecated) {
59
59
  return;
60
60
  }
61
61
 
@@ -61,6 +61,10 @@ const reservedKeywords = new Set([
61
61
  * Escaping is done by adding an underscore prefix.
62
62
  */
63
63
  function escapeIdentifier(name) {
64
+ if (!name) {
65
+ return name;
66
+ }
67
+
64
68
  if (reservedKeywords.has(name) || /^[0-9]/.test(name)) {
65
69
  return `_${name}`;
66
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swaggie",
3
- "version": "1.3.0-test.2",
3
+ "version": "1.3.0-test.3",
4
4
  "description": "Generate TypeScript REST client code from an OpenAPI spec",
5
5
  "author": {
6
6
  "name": "Piotr Dabrowski",