Skip to content

Commit

Permalink
chore: suggestion to contact support in case of certain errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleh Shumov committed Dec 17, 2024
1 parent 3721546 commit 304072d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/commands/openapi/refs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default class OpenAPIRefsCommand extends BaseCommand<typeof OpenAPIRefsCo
$ref: schema.$ref,
};
} else {
throw new Error(`Unsupported schema type for ${originalSchemaName}`);
throw new Error(`Unsupported schema type for ${originalSchemaName}. Please contact [email protected].`);
}

OpenAPIRefsCommand.replaceRefsInSchema(schemas[refSchemaName], circularRefs, refSchemaName);
Expand All @@ -184,7 +184,7 @@ export default class OpenAPIRefsCommand extends BaseCommand<typeof OpenAPIRefsCo
circularRefs.forEach(refPath => {
const refParts = refPath.split('/');
if (refParts.length < 4) {
throw new Error(`Invalid reference path: ${refPath}`);
throw new Error(`Invalid reference path: ${refPath}. Please contact [email protected].`);
}

const schemaName = refParts[3];
Expand All @@ -198,11 +198,13 @@ export default class OpenAPIRefsCommand extends BaseCommand<typeof OpenAPIRefsCo
} else if ('$ref' in schema && schema.$ref) {
property = { $ref: schema.$ref };
} else {
throw new Error(`Property "${propertyName}" is not found or schema is invalid.`);
throw new Error(
`Property "${propertyName}" is not found or schema is invalid. Please contact [email protected].`,
);
}

if (!schema || !property) {
throw new Error(`Schema or property not found for path: ${refPath}`);
throw new Error(`Schema or property not found for path: ${refPath}. Please contact [email protected].`);
}

if ('$ref' in property) {
Expand All @@ -217,7 +219,7 @@ export default class OpenAPIRefsCommand extends BaseCommand<typeof OpenAPIRefsCo
createRefSchema(refSchemaName, newRefSchemaName);
return;
}
throw new Error(`Invalid $ref in property: ${JSON.stringify(property)}`);
throw new Error(`Invalid $ref in property: ${JSON.stringify(property)}. Please contact [email protected].`);
}

// Handle references within items in an array
Expand Down Expand Up @@ -258,7 +260,7 @@ export default class OpenAPIRefsCommand extends BaseCommand<typeof OpenAPIRefsCo
circularRefs.forEach(refPath => {
const refParts = refPath.split('/');
if (refParts.length < 4) {
throw new Error(`Invalid reference path: ${refPath}`);
throw new Error(`Invalid reference path: ${refPath}. Please contact [email protected].`);
}

const schemaName = refParts[3];
Expand All @@ -277,7 +279,7 @@ export default class OpenAPIRefsCommand extends BaseCommand<typeof OpenAPIRefsCo
} else if ('$ref' in schema && typeof schema.$ref === 'string') {
schema = { type: 'object' };
} else {
throw new Error(`Invalid schema format: ${JSON.stringify(schema)}`);
throw new Error(`Invalid schema format: ${JSON.stringify(schema)}. Please contact [email protected].`);
}
});
}
Expand Down Expand Up @@ -342,7 +344,9 @@ export default class OpenAPIRefsCommand extends BaseCommand<typeof OpenAPIRefsCo

if (remainingCircularRefs.length > 0) {
debug(`Final unresolved circular references: ${JSON.stringify(remainingCircularRefs, null, 2)}`);
throw new Error('Unable to resolve all circular references, even with fallback replacements.');
throw new Error(
'Unable to resolve all circular references, even with fallback replacements. Please contact [email protected].',
);
} else {
debug('All remaining circular references successfully replaced with empty objects.');
}
Expand Down

0 comments on commit 304072d

Please sign in to comment.