openapi-types: support x- specification extensions everywhere without a pre-existing index signature#899
Conversation
|
|
||
| export type PathsObject<T extends {} = {}, P extends {} = {}> = Record< | ||
| string, | ||
| `/${string}`, |
There was a problem hiding this comment.
/${string}, as the specification states.
We need to do this because otherwise this index signature (generic string) would shadow the x-${string} signature.
|
|
||
| export type ResponsesObject = Record< | ||
| string, | ||
| `${string}`, |
There was a problem hiding this comment.
| >; | ||
|
|
||
| // TODO comment | ||
| export type CallbackObject = Record<string, PathItemObject | ReferenceObject>; |
There was a problem hiding this comment.
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).
| } | ||
|
|
||
| // TODO comment | ||
| export interface CallbackObject { |
There was a problem hiding this comment.
| | SecuritySchemeOauth2Application; | ||
|
|
||
| // TODO comment | ||
| export interface ScopesObject { |
There was a problem hiding this comment.
|
|
||
| export interface ExternalDocumentationObject { | ||
| // TODO comment | ||
| [index: string]: any; |
There was a problem hiding this comment.
| } | ||
|
|
||
| // TODO comment | ||
| export interface XMLObject { |
There was a problem hiding this comment.
… a pre-existing index signature (fixes kogosoftwarellc#768)
| >; | ||
|
|
||
| export type DiscriminatorObject = OpenAPIV3.DiscriminatorObject; | ||
| export type DiscriminatorObject = OpenAPIV3.DiscriminatorObject & |
There was a problem hiding this comment.
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-typesdoes not support these yet.This PR introduces the
Extensibleinterface, 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!