-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
openapi-types: support x- specification extensions everywhere without a pre-existing index signature #899
base: main
Are you sure you want to change the base?
Conversation
@@ -92,9 +97,10 @@ export namespace OpenAPIV3_1 { | |||
>; | |||
|
|||
export type PathsObject<T extends {} = {}, P extends {} = {}> = Record< | |||
string, | |||
`/${string}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/${string}
, as the specification states.
We need to do this because otherwise this index signature (generic string
) would shadow the x-${string}
signature.
@@ -214,9 +222,10 @@ export namespace OpenAPIV3_1 { | |||
>; | |||
|
|||
export type ResponsesObject = Record< | |||
string, | |||
`${string}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/openapi-types/index.ts
Outdated
@@ -234,6 +243,7 @@ export namespace OpenAPIV3_1 { | |||
} | |||
>; | |||
|
|||
// TODO comment | |||
export type CallbackObject = Record<string, PathItemObject | ReferenceObject>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is extensible according to the specification, but a limitation of TypeScript means we can't add the x-${string}
signature as it would be shadowed by the string
one (which we can't constrain any further).
packages/openapi-types/index.ts
Outdated
@@ -509,6 +523,7 @@ export namespace OpenAPIV3 { | |||
server?: ServerObject; | |||
} | |||
|
|||
// TODO comment | |||
export interface CallbackObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/openapi-types/index.ts
Outdated
@@ -641,6 +656,7 @@ export namespace OpenAPIV2 { | |||
| SecuritySchemeOauth2Password | |||
| SecuritySchemeOauth2Application; | |||
|
|||
// TODO comment | |||
export interface ScopesObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/openapi-types/index.ts
Outdated
@@ -817,12 +829,13 @@ export namespace OpenAPIV2 { | |||
} | |||
|
|||
export interface ExternalDocumentationObject { | |||
// TODO comment | |||
[index: string]: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/openapi-types/index.ts
Outdated
@@ -843,6 +856,7 @@ export namespace OpenAPIV2 { | |||
$ref?: string; | |||
} | |||
|
|||
// TODO comment | |||
export interface XMLObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… a pre-existing index signature (fixes kogosoftwarellc#768)
@@ -182,7 +188,8 @@ export namespace OpenAPIV3_1 { | |||
} | |||
>; | |||
|
|||
export type DiscriminatorObject = OpenAPIV3.DiscriminatorObject; | |||
export type DiscriminatorObject = OpenAPIV3.DiscriminatorObject & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is extensible in 3.1, but not in 3.0 (or at least the specification doesn't explicitly call this out).
@mitchell-merry can you resolve conflicts and ensure a passing build? |
Merge conflict resolved, though it looks like you need to approve the build to be run |
Fixes #768
Per the Swagger 2.0, OpenAPI 3.0, and OpenAPI 3.1 specs, most objects should support
^x-
properties for the purposes of extending the specification. However,openapi-types
does not support these yet.This PR introduces the
Extensible
interface, which is used to specify the types that should support this. It also bumps the prettier package to 2.2.0, which is the earliest version which supports TypeScript templating strings.As is, this PR contains breaking changes to the types, to better fit the specfication! See details in the comments.
Interested to hear your thoughts!