Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update file to fix ts-ignore errors
  • Loading branch information
Anmol1696 committed Sep 24, 2025
commit 1e1aec4d0f183c506842ea837ce243b71d3f3793
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"clean": "lerna run clean",
"build": "lerna run build --stream",
"lint": "lerna run lint --parallel",
"test": "NODE_OPTIONS=--no-deprecation jest",
"symlink": "symlink-workspace --logLevel error",
"postinstall": "yarn symlink"
},
Expand Down
50 changes: 15 additions & 35 deletions packages/schema-sdk/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ const shouldIncludeOperation = (
path: string,
method: MethodType
) => {
// @ts-ignore
const operation: Operation = pathItem[method];
const operation: Operation | undefined = pathItem[method];
Copy link
Preview

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type assertion is incorrect. pathItem[method] should be cast as pathItem[method as keyof OpenAPIPathItem] as Operation | undefined to properly access the method property on the pathItem object.

Suggested change
const operation: Operation | undefined = pathItem[method];
const operation: Operation | undefined = pathItem[method as keyof OpenAPIPathItem] as Operation | undefined;

Copilot uses AI. Check for mistakes.


if (!operation) return false;

Expand All @@ -80,7 +79,7 @@ const shouldIncludeOperation = (

if (!shouldIncludeByPath) return false;

const shouldIncludeByTag = operation.tags.some((tag) =>
const shouldIncludeByTag = (operation.tags || []).some((tag) =>
shouldInclude(tag, {
include: options.paths?.includeTags ?? [],
exclude: options.paths?.excludeTags ?? [],
Expand Down Expand Up @@ -313,32 +312,19 @@ export function generateOpenApiParams(
['get', 'post', 'put', 'delete', 'options', 'head', 'patch'].forEach(
(method) => {
if (Object.prototype.hasOwnProperty.call(pathItem, method)) {
// @ts-ignore
const operation: Operation = pathItem[method];
if (!shouldIncludeOperation(options, pathItem, path, method as any))
const operation: Operation | undefined = pathItem[method as keyof OpenAPIPathItem] as Operation | undefined;
Copy link
Preview

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This type assertion pattern is repeated multiple times throughout the file. Consider extracting this into a helper function like getOperationFromPathItem(pathItem: OpenAPIPathItem, method: string): Operation | undefined to reduce duplication and improve maintainability.

Copilot uses AI. Check for mistakes.

if (!operation || !shouldIncludeOperation(options, pathItem, path, method as any))
return;

// @ts-ignore
const methodType:
| 'get'
| 'post'
| 'put'
| 'delete'
| 'options'
| 'head'
| 'patch' = method;
const methodType = method as MethodType;

// @ts-ignore
const opParamMethod: ParameterInterfaces = opParams[method];
const opParamMethod: ParameterInterfaces = opParams[methodType];

const props: t.TSPropertySignature[] = [];

Object.keys(opParamMethod).forEach((key) => {
// @ts-ignore
const params: Parameter[] = opParamMethod[key];
// @ts-ignore
const paramType: 'query' | 'body' | 'formData' | 'header' | 'path' =
key;
const params: Parameter[] = opParamMethod[key as keyof ParameterInterfaces];
const paramType = key as 'query' | 'body' | 'formData' | 'header' | 'path';

// only include body sometimes
if (
Expand Down Expand Up @@ -446,13 +432,11 @@ export function getOpenApiParams(
['get', 'post', 'put', 'delete', 'options', 'head', 'patch'].forEach(
(method) => {
if (Object.prototype.hasOwnProperty.call(pathItem, method)) {
// @ts-ignore
const operation: Operation = pathItem[method];
if (!shouldIncludeOperation(options, pathItem, path, method as any))
const operation: Operation | undefined = pathItem[method as keyof OpenAPIPathItem] as Operation | undefined;
if (!operation || !shouldIncludeOperation(options, pathItem, path, method as any))
return;

// @ts-ignore
const opParamMethod: ParameterInterfaces = opParams[method];
const opParamMethod: ParameterInterfaces = opParams[method as keyof OpParameterInterfaces];

// push Path-Level params into op
opParamMethod.path.push(...opParams.pathLevel.path);
Expand Down Expand Up @@ -642,8 +626,7 @@ function generateGVKOpsStatements(
// Extract GVK metadata from paths section (where it actually exists in many schemas)
Object.entries(patchedSchema.paths).forEach(([path, pathItem]) => {
METHOD_TYPES.forEach((m) => {
// @ts-ignore
const operation: Operation = (pathItem as any)[m];
const operation: Operation | undefined = pathItem[m as keyof OpenAPIPathItem] as Operation | undefined;
if (!operation || !shouldIncludeOperation(options, pathItem, path, m as any)) return;

// Check for GVK metadata in the operation
Expand Down Expand Up @@ -677,8 +660,7 @@ function generateGVKOpsStatements(
const pathBaseToDef = new Map<string, string>();
Object.entries(patchedSchema.paths).forEach(([path, pathItem]) => {
METHOD_TYPES.forEach((m) => {
// @ts-ignore
const operation: Operation = (pathItem as any)[m];
const operation: Operation | undefined = pathItem[m as keyof OpenAPIPathItem] as Operation | undefined;
if (!operation || !shouldIncludeOperation(options, pathItem, path, m as any)) return;
const retDef = getRefDefName(operation.responses?.['200']);
const bodyParam = (operation.parameters || []).find((p) => p.in === 'body' && (p.schema as any)?.$ref);
Expand All @@ -695,8 +677,7 @@ function generateGVKOpsStatements(
const map = new Map<string, GVKEntry>();
Object.entries(patchedSchema.paths).forEach(([path, pathItem]) => {
METHOD_TYPES.forEach((m) => {
// @ts-ignore
const operation: Operation = (pathItem as any)[m];
const operation: Operation | undefined = pathItem[m as keyof OpenAPIPathItem] as Operation | undefined;
if (!operation || !shouldIncludeOperation(options, pathItem, path, m as any)) return;
const kind = classifyOperation(operation.operationId, m);
if (kind === 'watch' || kind === 'unknown') return;
Expand Down Expand Up @@ -954,8 +935,7 @@ function buildInterfaceRenameMapFromSchema(
// Extract GVK metadata from paths section (where it actually exists in many schemas)
Object.entries(schema.paths).forEach(([path, pathItem]) => {
METHOD_TYPES.forEach((m) => {
// @ts-ignore
const operation: Operation = (pathItem as any)[m];
const operation: Operation | undefined = pathItem[m as keyof OpenAPIPathItem] as Operation | undefined;
if (!operation || !shouldIncludeOperation(options, pathItem, path, m as any)) return;

// Check for GVK metadata in the operation
Expand Down