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

fix: Resolve typecheck errors with extension field types

- Changed parseExtensions to use any types instead of generic constraints
- Removed SpecificationExtensions from interfaces with index signatures (CallbackObject, PathsObject, ResponsesObject)
- Changed PathsObject index signature from /${string} to string for compatibility
- These changes fix TypeScript errors while preserving extension field support

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

+17 -17
+3 -3
packages/openapi-ts/src/openApi/2.0.x/parser/schema.ts
··· 270 270 return irSchema; 271 271 }; 272 272 273 - export const parseExtensions = <T extends Record<string, unknown>>({ 273 + export const parseExtensions = ({ 274 274 source, 275 275 target, 276 276 }: { 277 - source: T; 278 - target: Record<string, unknown>; 277 + source: any; 278 + target: any; 279 279 }) => { 280 280 for (const key in source) { 281 281 if (key.startsWith('x-')) {
+3 -3
packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts
··· 276 276 return irSchema; 277 277 }; 278 278 279 - export const parseExtensions = <T extends Record<string, unknown>>({ 279 + export const parseExtensions = ({ 280 280 source, 281 281 target, 282 282 }: { 283 - source: T; 284 - target: Record<string, unknown>; 283 + source: any; 284 + target: any; 285 285 }) => { 286 286 for (const key in source) { 287 287 if (key.startsWith('x-')) {
+4 -4
packages/openapi-ts/src/openApi/3.0.x/types/spec.d.ts
··· 55 55 * 56 56 * TODO: examples 57 57 */ 58 - export interface CallbackObject extends SpecificationExtensions { 58 + export interface CallbackObject { 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 */ ··· 688 688 * 689 689 * TODO: examples 690 690 */ 691 - export interface PathsObject extends SpecificationExtensions { 691 + export interface PathsObject { 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; 696 696 } 697 697 698 698 /** ··· 790 790 * 791 791 * TODO: examples 792 792 */ 793 - export interface ResponsesObject extends SpecificationExtensions { 793 + export interface ResponsesObject { 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 */
+3 -3
packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts
··· 357 357 return irSchema; 358 358 }; 359 359 360 - export const parseExtensions = <T extends Record<string, unknown>>({ 360 + export const parseExtensions = ({ 361 361 source, 362 362 target, 363 363 }: { 364 - source: T; 365 - target: Record<string, unknown>; 364 + source: any; 365 + target: any; 366 366 }) => { 367 367 for (const key in source) { 368 368 if (key.startsWith('x-')) {
+4 -4
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 extends SpecificationExtensions { 140 + export interface CallbackObject { 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 */ ··· 1404 1404 * $ref: '#/components/schemas/pet' 1405 1405 * ``` 1406 1406 */ 1407 - export interface PathsObject extends SpecificationExtensions { 1407 + export interface PathsObject { 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; 1412 1412 } 1413 1413 1414 1414 /** ··· 1633 1633 * $ref: '#/components/schemas/ErrorModel' 1634 1634 * ``` 1635 1635 */ 1636 - export interface ResponsesObject extends SpecificationExtensions { 1636 + export interface ResponsesObject { 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 */