fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: Correct extension field type handling per review feedback

- Changed parseExtensions to use Record<string, unknown> instead of any
- Added type assertions at call sites for type safety
- Restored SpecificationExtensions to CallbackObject, PathsObject, ResponsesObject
- Kept PathsObject with [path: /${string}] template literal type
- Extended index signatures with | unknown to satisfy TypeScript

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>

+44 -36
+2 -2
packages/openapi-ts/src/openApi/2.0.x/parser/operation.ts
··· 78 78 }); 79 79 80 80 parseExtensions({ 81 - source: operation, 82 - target: irOperation, 81 + source: operation as Record<string, unknown>, 82 + target: irOperation as Record<string, unknown>, 83 83 }); 84 84 85 85 return irOperation;
+2 -2
packages/openapi-ts/src/openApi/2.0.x/parser/parameter.ts
··· 166 166 } 167 167 168 168 parseExtensions({ 169 - source: parameter, 170 - target: irParameter, 169 + source: parameter as Record<string, unknown>, 170 + target: irParameter as Record<string, unknown>, 171 171 }); 172 172 173 173 return irParameter;
+4 -4
packages/openapi-ts/src/openApi/2.0.x/parser/schema.ts
··· 274 274 source, 275 275 target, 276 276 }: { 277 - source: any; 278 - target: any; 277 + source: Record<string, unknown>; 278 + target: Record<string, unknown>; 279 279 }) => { 280 280 for (const key in source) { 281 281 if (key.startsWith('x-')) { ··· 297 297 }); 298 298 299 299 parseExtensions({ 300 - source: schema, 301 - target: irSchema, 300 + source: schema as Record<string, unknown>, 301 + target: irSchema as Record<string, unknown>, 302 302 }); 303 303 304 304 return irSchema;
+2 -2
packages/openapi-ts/src/openApi/3.0.x/parser/operation.ts
··· 75 75 }); 76 76 77 77 parseExtensions({ 78 - source: operation, 79 - target: irOperation, 78 + source: operation as Record<string, unknown>, 79 + target: irOperation as Record<string, unknown>, 80 80 }); 81 81 82 82 return irOperation;
+2 -2
packages/openapi-ts/src/openApi/3.0.x/parser/parameter.ts
··· 174 174 } 175 175 176 176 parseExtensions({ 177 - source: parameter, 178 - target: irParameter, 177 + source: parameter as Record<string, unknown>, 178 + target: irParameter as Record<string, unknown>, 179 179 }); 180 180 181 181 return irParameter;
+4 -4
packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts
··· 280 280 source, 281 281 target, 282 282 }: { 283 - source: any; 284 - target: any; 283 + source: Record<string, unknown>; 284 + target: Record<string, unknown>; 285 285 }) => { 286 286 for (const key in source) { 287 287 if (key.startsWith('x-')) { ··· 303 303 }); 304 304 305 305 parseExtensions({ 306 - source: schema, 307 - target: irSchema, 306 + source: schema as Record<string, unknown>, 307 + target: irSchema as Record<string, unknown>, 308 308 }); 309 309 310 310 return irSchema;
+10 -6
packages/openapi-ts/src/openApi/3.0.x/types/spec.d.ts
··· 55 55 * 56 56 * TODO: examples 57 57 */ 58 - export interface CallbackObject { 58 + export interface CallbackObject extends SpecificationExtensions { 59 59 /** 60 60 * A Path Item Object used to define a callback request and expected responses. A {@link https://learn.openapis.org/examples/v3.0/callback-example.html complete example} is available. 61 61 */ 62 - [expression: string]: PathItemObject | ReferenceObject; 62 + [expression: string]: PathItemObject | ReferenceObject | unknown; 63 63 } 64 64 65 65 /** ··· 688 688 * 689 689 * TODO: examples 690 690 */ 691 - export interface PathsObject { 691 + export interface PathsObject extends SpecificationExtensions { 692 692 /** 693 693 * A relative path to an individual endpoint. The field name MUST begin with a forward slash (`/`). The path is **appended** (no relative URL resolution) to the expanded URL from the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#server-object Server Object}'s `url` field in order to construct the full URL. {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#path-templating Path templating} is allowed. When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical. In case of ambiguous matching, it's up to the tooling to decide which one to use. 694 694 */ 695 - [path: string]: PathItemObject; 695 + [path: `/${string}`]: PathItemObject | unknown; 696 696 } 697 697 698 698 /** ··· 790 790 * 791 791 * TODO: examples 792 792 */ 793 - export interface ResponsesObject { 793 + export interface ResponsesObject extends SpecificationExtensions { 794 794 /** 795 795 * Any {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#http-status-codes HTTP status code} can be used as the property name, but only one property per code, to describe the expected response for that HTTP status code. A {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#reference-object Reference Object} can link to a response that is defined in the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#components-responses OpenAPI Object's `components.responses`} section. This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML. To define a range of response codes, this field MAY contain the uppercase wildcard character `X`. For example, `2XX` represents all response codes between `200` and `299`. Only the following range definitions are allowed: `1XX`, `2XX`, `3XX`, `4XX`, and `5XX`. If a response is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code. 796 796 */ 797 - [httpStatusCode: string]: ResponseObject | ReferenceObject | undefined; 797 + [httpStatusCode: string]: 798 + | ResponseObject 799 + | ReferenceObject 800 + | undefined 801 + | unknown; 798 802 /** 799 803 * The documentation of responses other than the ones declared for specific HTTP response codes. Use this field to cover undeclared responses. A {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#reference-object Reference Object} can link to a response that the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#components-responses OpenAPI Object's `components.responses`} section defines. 800 804 */
+2 -2
packages/openapi-ts/src/openApi/3.1.x/parser/operation.ts
··· 75 75 }); 76 76 77 77 parseExtensions({ 78 - source: operation, 79 - target: irOperation, 78 + source: operation as Record<string, unknown>, 79 + target: irOperation as Record<string, unknown>, 80 80 }); 81 81 82 82 return irOperation;
+2 -2
packages/openapi-ts/src/openApi/3.1.x/parser/parameter.ts
··· 167 167 } 168 168 169 169 parseExtensions({ 170 - source: parameter, 171 - target: irParameter, 170 + source: parameter as Record<string, unknown>, 171 + target: irParameter as Record<string, unknown>, 172 172 }); 173 173 174 174 return irParameter;
+4 -4
packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts
··· 361 361 source, 362 362 target, 363 363 }: { 364 - source: any; 365 - target: any; 364 + source: Record<string, unknown>; 365 + target: Record<string, unknown>; 366 366 }) => { 367 367 for (const key in source) { 368 368 if (key.startsWith('x-')) { ··· 384 384 }); 385 385 386 386 parseExtensions({ 387 - source: schema, 388 - target: irSchema, 387 + source: schema as Record<string, unknown>, 388 + target: irSchema as Record<string, unknown>, 389 389 }); 390 390 391 391 return irSchema;
+10 -6
packages/openapi-ts/src/openApi/3.1.x/types/spec.d.ts
··· 137 137 * description: callback successfully processed 138 138 * ``` 139 139 */ 140 - export interface CallbackObject { 140 + export interface CallbackObject extends SpecificationExtensions { 141 141 /** 142 142 * A Path Item Object, or a reference to one, used to define a callback request and expected responses. A {@link https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.0/callback-example.yaml complete example} is available. 143 143 */ 144 - [expression: string]: PathItemObject | ReferenceObject; 144 + [expression: string]: PathItemObject | ReferenceObject | unknown; 145 145 } 146 146 147 147 /** ··· 1404 1404 * $ref: '#/components/schemas/pet' 1405 1405 * ``` 1406 1406 */ 1407 - export interface PathsObject { 1407 + export interface PathsObject extends SpecificationExtensions { 1408 1408 /** 1409 1409 * A relative path to an individual endpoint. The field name MUST begin with a forward slash (`/`). The path is **appended** (no relative URL resolution) to the expanded URL from the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#server-object `Server Object`}'s `url` field in order to construct the full URL. {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#path-templating Path templating} is allowed. When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical. In case of ambiguous matching, it's up to the tooling to decide which one to use. 1410 1410 */ 1411 - [path: string]: PathItemObject; 1411 + [path: `/${string}`]: PathItemObject | unknown; 1412 1412 } 1413 1413 1414 1414 /** ··· 1633 1633 * $ref: '#/components/schemas/ErrorModel' 1634 1634 * ``` 1635 1635 */ 1636 - export interface ResponsesObject { 1636 + export interface ResponsesObject extends SpecificationExtensions { 1637 1637 /** 1638 1638 * Any {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#http-status-codes HTTP status code} can be used as the property name, but only one property per code, to describe the expected response for that HTTP status code. This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML. To define a range of response codes, this field MAY contain the uppercase wildcard character `X`. For example, `2XX` represents all response codes between `[200-299]`. Only the following range definitions are allowed: `1XX`, `2XX`, `3XX`, `4XX`, and `5XX`. If a response is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code. 1639 1639 */ 1640 - [httpStatusCode: string]: ResponseObject | ReferenceObject | undefined; 1640 + [httpStatusCode: string]: 1641 + | ResponseObject 1642 + | ReferenceObject 1643 + | undefined 1644 + | unknown; 1641 1645 /** 1642 1646 * The documentation of responses other than the ones declared for specific HTTP response codes. Use this field to cover undeclared responses. 1643 1647 */