Skip to content

Commit 620c6c1

Browse files
committed
Resolved type errors
1 parent 237a67a commit 620c6c1

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

src/openapi/index.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ class SchemaRegistry {
7272

7373
// Handle reference-only schemas
7474
if (this.isReferenceOnly(open)) {
75-
const ref = open.$ref!;
75+
const ref = (open as OpenAPIV3_1.ReferenceObject).$ref!;
7676
const name = this.extractSchemaNameFromRef(ref);
7777
if (name) {
7878
this.ids.set(schema, name);
79-
return open;
79+
return open as OpenAPIV3_1.ReferenceObject;
8080
}
8181
}
8282

@@ -141,7 +141,7 @@ class SchemaRegistry {
141141
if (schema.type === 'object') {
142142
const hasProperties =
143143
(schema.properties && Object.keys(schema.properties).length > 0) ||
144-
schema.patternProperties ||
144+
('patternProperties' in schema && schema.patternProperties) ||
145145
schema.additionalProperties !== undefined ||
146146
schema.minProperties !== undefined ||
147147
schema.maxProperties !== undefined;
@@ -235,11 +235,12 @@ export const createOpenApiSpecification = async (
235235
for (const [opId, op] of Object.entries(contract)) {
236236
const p = convertPathToOpenAPIFormat(op.path);
237237
if (!paths[p]) {
238-
paths[p] = {};
238+
paths[p] = {} as OpenAPIV3_1.PathItemObject;
239239
}
240-
const pathItem = paths[p]!;
241-
const method = op.method.toLowerCase() as HttpMethod;
242-
pathItem[method] = await createOpenApiOperation(op, reg, opId);
240+
const pathItem = paths[p]! as OpenAPIV3_1.PathItemObject;
241+
const method = op.method.toLowerCase() as Lowercase<HttpMethod>;
242+
const operation = await createOpenApiOperation(op, reg, opId);
243+
(pathItem as any)[method] = operation;
243244
}
244245

245246
return {
@@ -389,7 +390,7 @@ async function makeParameters(
389390
name,
390391
in: 'path',
391392
required: isRequired,
392-
schema: cleanSchema,
393+
schema: cleanSchema as OpenAPIV3_1.ParameterObject['schema'],
393394
description,
394395
};
395396
} else {
@@ -425,7 +426,7 @@ async function makeParameters(
425426
name,
426427
in: location,
427428
required: isRequired,
428-
schema: cleanSchema,
429+
schema: cleanSchema as OpenAPIV3_1.ParameterObject['schema'],
429430
description,
430431
};
431432
});
@@ -538,11 +539,12 @@ export const createOpenApiPaths = async (
538539
for (const [operationId, operation] of Object.entries(contract)) {
539540
const openApiPath = convertPathToOpenAPIFormat(operation.path);
540541
if (!paths[openApiPath]) {
541-
paths[openApiPath] = {};
542+
paths[openApiPath] = {} as OpenAPIV3_1.PathItemObject;
542543
}
543-
const pathItem = paths[openApiPath]!;
544+
const pathItem = paths[openApiPath]! as OpenAPIV3_1.PathItemObject;
544545
const method = operation.method.toLowerCase() as Lowercase<HttpMethod>;
545-
pathItem[method] = await createOpenApiOperation(operation, registry, operationId);
546+
const op = await createOpenApiOperation(operation, registry, operationId);
547+
(pathItem as any)[method] = op;
546548
}
547549
return paths;
548550
};

0 commit comments

Comments
 (0)