-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feature): support asyncapi examples via
x-fern-examples
(#3042)
support asyncapi examples via extension
- Loading branch information
Showing
32 changed files
with
235 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/cli/openapi-parser/src/asyncapi/fernExtensions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Values } from "@fern-api/core-utils"; | ||
|
||
export const FernAsyncAPIExtension = { | ||
/** | ||
* The x-fern-examples allows you to specify examples for the websocket session. | ||
* | ||
* channels: | ||
* /my-channel: | ||
* subscribe: | ||
* ... | ||
* | ||
* x-fern-examples: | ||
* - name: example-1 | ||
* summary: This is an example of a websocket session | ||
* description: This is a description of the example | ||
* messages: | ||
* - type: publish | ||
* messageId: SendMessage | ||
* value: | ||
* data: "1223233" | ||
* - type: subscribe | ||
* messageId: ReceiveMessage | ||
* value: | ||
* data: "12340213" | ||
*/ | ||
FERN_EXAMPLES: "x-fern-examples" | ||
} as const; | ||
|
||
export type FernAsyncAPIExtension = Values<typeof FernAsyncAPIExtension>; |
20 changes: 20 additions & 0 deletions
20
packages/cli/openapi-parser/src/asyncapi/getFernExamples.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { getExtension } from "../getExtension"; | ||
import { FernAsyncAPIExtension } from "./fernExtensions"; | ||
import { AsyncAPIV2 } from "./v2"; | ||
|
||
export interface WebsocketSessionExampleExtension { | ||
summary?: string; | ||
description?: string; | ||
queryParameters?: Record<string, string>; | ||
headers?: Record<string, string>; | ||
messages: { | ||
type: "subscribe" | "publish"; | ||
messageId: string; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
value: any; | ||
}[]; | ||
} | ||
|
||
export function getFernExamples(channel: AsyncAPIV2.Channel): WebsocketSessionExampleExtension[] { | ||
return getExtension<WebsocketSessionExampleExtension[]>(channel, FernAsyncAPIExtension.FERN_EXAMPLES) ?? []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...src/openapi/v3/extensions/getExtension.ts → ...es/cli/openapi-parser/src/getExtension.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/cli/openapi-parser/src/openapi/v3/converters/convertSecurityScheme.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/cli/openapi-parser/src/openapi/v3/converters/convertServer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/convertRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/convertResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/getApplicationJsonSchema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/cli/openapi-parser/src/openapi/v3/converters/operation/convertHttpOperation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/cli/openapi-parser/src/openapi/v3/converters/operation/convertOperation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.