diff --git a/packages/cli/openapi-parser/src/__test__/__snapshots__/assembly.test.ts.snap b/packages/cli/openapi-parser/src/__test__/__snapshots__/assembly.test.ts.snap index c5f8abdcf91..13fadf20b6a 100644 --- a/packages/cli/openapi-parser/src/__test__/__snapshots__/assembly.test.ts.snap +++ b/packages/cli/openapi-parser/src/__test__/__snapshots__/assembly.test.ts.snap @@ -28,28 +28,18 @@ exports[`open api parser assembly parse open api 1`] = ` }, { "description": null, - "messageType": "subscribe", + "messageType": "publish", "payload": { "properties": { - "expires_at": { - "type": "primitive", - "value": { - "type": "datetime", - "value": "2024-01-15T09:30:00.000Z", - }, - }, "message_type": { - "type": "literal", - "value": { - "type": "string", - "value": "SessionBegins", - }, + "type": "enum", + "value": "SessionBegins", }, - "session_id": { + "terminate_session": { "type": "primitive", "value": { - "type": "string", - "value": "session_id", + "type": "boolean", + "value": true, }, }, }, diff --git a/packages/cli/openapi-parser/src/__test__/fixtures/assembly/asyncapi.yml b/packages/cli/openapi-parser/src/__test__/fixtures/assembly/asyncapi.yml index ec8c6f1dcd5..167c5d06436 100644 --- a/packages/cli/openapi-parser/src/__test__/fixtures/assembly/asyncapi.yml +++ b/packages/cli/openapi-parser/src/__test__/fixtures/assembly/asyncapi.yml @@ -70,6 +70,17 @@ channels: - $ref: "#/components/messages/FinalTranscript" - $ref: "#/components/messages/SessionTerminated" - $ref: "#/components/messages/RealtimeError" + + x-fern-examples: + - messages: + - messageId: SendAudio + type: publish + payload: + audio_data: "base64-encoded-audio-data" + - messageId: TerminateSession + type: publish + payload: + terminate_session: true components: messages: diff --git a/packages/cli/openapi-parser/src/asyncapi/ExampleWebsocketSessionFactory.ts b/packages/cli/openapi-parser/src/asyncapi/ExampleWebsocketSessionFactory.ts index 303d45cc1f2..4f44a210ad3 100644 --- a/packages/cli/openapi-parser/src/asyncapi/ExampleWebsocketSessionFactory.ts +++ b/packages/cli/openapi-parser/src/asyncapi/ExampleWebsocketSessionFactory.ts @@ -4,11 +4,16 @@ import { QueryParameterExample, SchemaWithExample, WebsocketHandshakeWithExample, + WebsocketMessageExample, WebsocketSessionExample } from "@fern-api/openapi-ir-sdk"; import { isExamplePrimitive } from "../openapi/v3/converters/ExampleEndpointFactory"; +import { convertSchema } from "../schema/convertSchemas"; import { ExampleTypeFactory } from "../schema/examples/ExampleTypeFactory"; +import { isReferenceObject } from "../schema/utils/isReferenceObject"; import { isSchemaRequired } from "../schema/utils/isSchemaRequired"; +import { AsyncAPIV2ParserContext } from "./AsyncAPIParserContext"; +import { WebsocketSessionExampleExtension } from "./getFernExamples"; export class ExampleWebsocketSessionFactory { private exampleTypeFactory: ExampleTypeFactory; @@ -19,6 +24,110 @@ export class ExampleWebsocketSessionFactory { this.schemas = schemas; } + public buildWebsocketSessionExamplesForExtension({ + context, + extensionExamples, + publish, + subscribe, + handshake + }: { + context: AsyncAPIV2ParserContext; + extensionExamples: WebsocketSessionExampleExtension[]; + handshake: WebsocketHandshakeWithExample; + publish: SchemaWithExample | undefined; + subscribe: SchemaWithExample | undefined; + }): WebsocketSessionExample[] { + const result: WebsocketSessionExample[] = []; + + for (const extensionExample of extensionExamples) { + const queryParameters: QueryParameterExample[] = []; + + for (const queryParameter of handshake.queryParameters) { + const required = this.isSchemaRequired(queryParameter.schema); + let example = this.exampleTypeFactory.buildExample({ + schema: queryParameter.schema, + example: extensionExample.queryParameters?.[queryParameter.name], + options: { + name: queryParameter.name, + isParameter: true, + ignoreOptionals: true + } + }); + if (example != null && !isExamplePrimitive(example)) { + example = undefined; + } + if (required && example == null) { + continue; + } else if (example != null) { + queryParameters.push({ + name: queryParameter.name, + value: example + }); + } + } + + const headers: HeaderExample[] = []; + for (const header of handshake.headers) { + const required = this.isSchemaRequired(header.schema); + let example = this.exampleTypeFactory.buildExample({ + schema: header.schema, + example: extensionExample.headers?.[header.name], + options: { + name: header.name, + isParameter: true, + ignoreOptionals: true + } + }); + if (example != null && !isExamplePrimitive(example)) { + example = undefined; + } + if (required && example == null) { + continue; + } else if (example != null) { + headers.push({ + name: header.name, + value: example + }); + } + } + + const messages: WebsocketMessageExample[] = []; + for (const messageExample of extensionExample.messages) { + const messageSchema = context.resolveMessageReference({ + $ref: `#/components/messages/${messageExample.messageId}` + }); + const resolvedSchema = isReferenceObject(messageSchema.payload) + ? context.resolveSchemaReference(messageSchema.payload) + : messageSchema.payload; + const example = this.exampleTypeFactory.buildExample({ + schema: convertSchema(resolvedSchema, false, context, [messageExample.messageId]), + example: messageExample.value, + options: { + isParameter: false, + ignoreOptionals: true + } + }); + if (example != null) { + messages.push({ + messageType: messageExample.type, + payload: example, + description: undefined + }); + } + } + + result.push({ + name: extensionExample.summary, + queryParameters, + headers, + description: extensionExample.description, + messages + }); + } + + return result; + } + public buildWebsocketSessionExample({ publish, subscribe, diff --git a/packages/cli/openapi-parser/src/asyncapi/fernExtensions.ts b/packages/cli/openapi-parser/src/asyncapi/fernExtensions.ts new file mode 100644 index 00000000000..66448d048e1 --- /dev/null +++ b/packages/cli/openapi-parser/src/asyncapi/fernExtensions.ts @@ -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; diff --git a/packages/cli/openapi-parser/src/asyncapi/getFernExamples.ts b/packages/cli/openapi-parser/src/asyncapi/getFernExamples.ts new file mode 100644 index 00000000000..a173232b110 --- /dev/null +++ b/packages/cli/openapi-parser/src/asyncapi/getFernExamples.ts @@ -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; + headers?: Record; + 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(channel, FernAsyncAPIExtension.FERN_EXAMPLES) ?? []; +} diff --git a/packages/cli/openapi-parser/src/asyncapi/parse.ts b/packages/cli/openapi-parser/src/asyncapi/parse.ts index 48958623037..4389bda91b0 100644 --- a/packages/cli/openapi-parser/src/asyncapi/parse.ts +++ b/packages/cli/openapi-parser/src/asyncapi/parse.ts @@ -4,7 +4,8 @@ import { Schema, SchemaId, SchemaWithExample, - WebsocketChannel + WebsocketChannel, + WebsocketSessionExample } from "@fern-api/openapi-ir-sdk"; import { TaskContext } from "@fern-api/task-context"; import { OpenAPIV3 } from "openapi-types"; @@ -14,6 +15,7 @@ import { convertSchemaWithExampleToSchema } from "../schema/utils/convertSchemaW import { isReferenceObject } from "../schema/utils/isReferenceObject"; import { AsyncAPIV2ParserContext } from "./AsyncAPIParserContext"; import { ExampleWebsocketSessionFactory } from "./ExampleWebsocketSessionFactory"; +import { getFernExamples, WebsocketSessionExampleExtension } from "./getFernExamples"; import { AsyncAPIV2 } from "./v2"; export interface AsyncAPIIntermediateRepresentation { @@ -104,14 +106,33 @@ export function parseAsyncAPI({ } if (headers.length > 0 || queryParameters.length > 0 || publishSchema != null || subscribeSchema != null) { - const example = exampleFactory.buildWebsocketSessionExample({ - handshake: { - headers, - queryParameters - }, - publish: publishSchema, - subscribe: subscribeSchema - }); + // Reads the `x-fern-examples` extension from the channel + const fernExamples: WebsocketSessionExampleExtension[] = getFernExamples(channel); + let examples: WebsocketSessionExample[] = []; + if (fernExamples.length > 0) { + examples = exampleFactory.buildWebsocketSessionExamplesForExtension({ + context, + extensionExamples: fernExamples, + handshake: { + headers, + queryParameters + }, + publish: publishSchema, + subscribe: subscribeSchema + }); + } else { + const autogenExample = exampleFactory.buildWebsocketSessionExample({ + handshake: { + headers, + queryParameters + }, + publish: publishSchema, + subscribe: subscribeSchema + }); + if (autogenExample != null) { + examples.push(autogenExample); + } + } const tag = document.tags?.[0]; parsedChannel = { @@ -136,7 +157,7 @@ export function parseAsyncAPI({ summary: undefined, path: channelPath, description: undefined, - examples: example != null ? [example] : [] + examples }; break; } diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getExtension.ts b/packages/cli/openapi-parser/src/getExtension.ts similarity index 72% rename from packages/cli/openapi-parser/src/openapi/v3/extensions/getExtension.ts rename to packages/cli/openapi-parser/src/getExtension.ts index b1da058aa17..ef4a1619da0 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getExtension.ts +++ b/packages/cli/openapi-parser/src/getExtension.ts @@ -1,6 +1,6 @@ -import { OpenAPIExtension } from "./extensions"; -import { FernOpenAPIExtension } from "./fernExtensions"; -import { ReadmeOpenAPIExtension } from "./readmeExtensions"; +import { OpenAPIExtension } from "./openapi/v3/extensions/extensions"; +import { FernOpenAPIExtension } from "./openapi/v3/extensions/fernExtensions"; +import { ReadmeOpenAPIExtension } from "./openapi/v3/extensions/readmeExtensions"; export function getExtension( object: object, diff --git a/packages/cli/openapi-parser/src/openapi/v3/converters/convertSecurityScheme.ts b/packages/cli/openapi-parser/src/openapi/v3/converters/convertSecurityScheme.ts index 22c1e240afd..c85b7c9a0c6 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/converters/convertSecurityScheme.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/converters/convertSecurityScheme.ts @@ -1,12 +1,12 @@ import { EnumSchema, SecurityScheme } from "@fern-api/openapi-ir-sdk"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { convertEnum } from "../../../schema/convertEnum"; import { convertSchemaWithExampleToSchema } from "../../../schema/utils/convertSchemaWithExampleToSchema"; import { isReferenceObject } from "../../../schema/utils/isReferenceObject"; import { OpenAPIExtension } from "../extensions/extensions"; import { FernOpenAPIExtension } from "../extensions/fernExtensions"; import { getBasicSecuritySchemeNames } from "../extensions/getBasicSecuritySchemeNames"; -import { getExtension } from "../extensions/getExtension"; import { getBasicSecuritySchemeNameAndEnvvar, SecuritySchemeNames diff --git a/packages/cli/openapi-parser/src/openapi/v3/converters/convertServer.ts b/packages/cli/openapi-parser/src/openapi/v3/converters/convertServer.ts index 23b18457b11..16402104303 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/converters/convertServer.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/converters/convertServer.ts @@ -1,7 +1,7 @@ import { Server } from "@fern-api/openapi-ir-sdk"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "../extensions/fernExtensions"; -import { getExtension } from "../extensions/getExtension"; export function convertServer(server: OpenAPIV3.ServerObject): Server { return { diff --git a/packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/convertRequest.ts b/packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/convertRequest.ts index 63fb8e3f480..c480aa7d7e2 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/convertRequest.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/convertRequest.ts @@ -1,11 +1,11 @@ import { MultipartSchema, RequestWithExample } from "@fern-api/openapi-ir-sdk"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../../getExtension"; import { convertSchema, getSchemaIdFromReference, SCHEMA_REFERENCE_PREFIX } from "../../../../schema/convertSchemas"; import { convertSchemaWithExampleToSchema } from "../../../../schema/utils/convertSchemaWithExampleToSchema"; import { isReferenceObject } from "../../../../schema/utils/isReferenceObject"; import { AbstractOpenAPIV3ParserContext } from "../../AbstractOpenAPIV3ParserContext"; import { FernOpenAPIExtension } from "../../extensions/fernExtensions"; -import { getExtension } from "../../extensions/getExtension"; import { getApplicationJsonSchemaMediaObject } from "./getApplicationJsonSchema"; export const APPLICATION_JSON_CONTENT = "application/json"; diff --git a/packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/convertResponse.ts b/packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/convertResponse.ts index 79d3ace2b52..cefcbc3260e 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/convertResponse.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/convertResponse.ts @@ -1,12 +1,12 @@ import { assertNever } from "@fern-api/core-utils"; import { ResponseWithExample, StatusCode } from "@fern-api/openapi-ir-sdk"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../../getExtension"; import { convertSchema } from "../../../../schema/convertSchemas"; import { convertSchemaWithExampleToSchema } from "../../../../schema/utils/convertSchemaWithExampleToSchema"; import { isReferenceObject } from "../../../../schema/utils/isReferenceObject"; import { AbstractOpenAPIV3ParserContext } from "../../AbstractOpenAPIV3ParserContext"; import { FernOpenAPIExtension } from "../../extensions/fernExtensions"; -import { getExtension } from "../../extensions/getExtension"; import { OperationContext } from "../contexts"; import { getApplicationJsonSchemaMediaObject } from "./getApplicationJsonSchema"; diff --git a/packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/getApplicationJsonSchema.ts b/packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/getApplicationJsonSchema.ts index 67e4bb23abc..bd9729f50eb 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/getApplicationJsonSchema.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/converters/endpoint/getApplicationJsonSchema.ts @@ -1,8 +1,8 @@ import { NamedFullExample } from "@fern-api/openapi-ir-sdk"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../../getExtension"; import { isReferenceObject } from "../../../../schema/utils/isReferenceObject"; import { OpenAPIExtension } from "../../extensions/extensions"; -import { getExtension } from "../../extensions/getExtension"; export interface ApplicationJsonMediaObject { schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject; diff --git a/packages/cli/openapi-parser/src/openapi/v3/converters/operation/convertHttpOperation.ts b/packages/cli/openapi-parser/src/openapi/v3/converters/operation/convertHttpOperation.ts index 8304e5b43c7..8e62fb97a71 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/converters/operation/convertHttpOperation.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/converters/operation/convertHttpOperation.ts @@ -1,11 +1,11 @@ import { EndpointWithExample } from "@fern-api/openapi-ir-sdk"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../../getExtension"; import { getGeneratedTypeName } from "../../../../schema/utils/getSchemaName"; import { AbstractOpenAPIV3ParserContext } from "../../AbstractOpenAPIV3ParserContext"; import { DummyOpenAPIV3ParserContext } from "../../DummyOpenAPIV3ParserContext"; import { OpenAPIExtension } from "../../extensions/extensions"; import { FernOpenAPIExtension } from "../../extensions/fernExtensions"; -import { getExtension } from "../../extensions/getExtension"; import { getFernAvailability } from "../../extensions/getFernAvailability"; import { getFernExamples } from "../../extensions/getFernExamples"; import { OperationContext } from "../contexts"; diff --git a/packages/cli/openapi-parser/src/openapi/v3/converters/operation/convertOperation.ts b/packages/cli/openapi-parser/src/openapi/v3/converters/operation/convertOperation.ts index d71f69a3fae..c03123095c5 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/converters/operation/convertOperation.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/converters/operation/convertOperation.ts @@ -1,9 +1,9 @@ import { EndpointSdkName, EndpointWithExample, HttpMethod, Webhook } from "@fern-api/openapi-ir-sdk"; import { camelCase } from "lodash-es"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../../getExtension"; import { AbstractOpenAPIV3ParserContext } from "../../AbstractOpenAPIV3ParserContext"; import { FernOpenAPIExtension } from "../../extensions/fernExtensions"; -import { getExtension } from "../../extensions/getExtension"; import { getFernAsyncExtension } from "../../extensions/getFernAsyncExtension"; import { getFernStreamingExtension } from "../../extensions/getFernStreamingExtension"; import { OperationContext, PathItemContext } from "../contexts"; diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getBasicSecuritySchemeNames.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getBasicSecuritySchemeNames.ts index 39f96752ac4..46f2bc98be4 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getBasicSecuritySchemeNames.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getBasicSecuritySchemeNames.ts @@ -1,6 +1,6 @@ import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export interface BasicSecuritySchemeNames { usernameVariable?: string; diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernAsyncExtension.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernAsyncExtension.ts index 3eb9b785330..e7b86198f1a 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernAsyncExtension.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernAsyncExtension.ts @@ -1,6 +1,6 @@ import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export interface AsyncFernExtensionSchema { discriminant: { diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernAvailability.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernAvailability.ts index db743957dd3..68b118324e7 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernAvailability.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernAvailability.ts @@ -1,7 +1,7 @@ import { EndpointAvailability } from "@fern-api/openapi-ir-sdk"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export interface BasicSecuritySchemeNames { usernameVariable?: string; diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernEnum.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernEnum.ts index 62886cddb8e..6c3c7625ec2 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernEnum.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernEnum.ts @@ -1,6 +1,6 @@ import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export interface CasingConfig { snake?: string; diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernExamples.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernExamples.ts index f06491edfa1..fb1d7bcac08 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernExamples.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernExamples.ts @@ -1,7 +1,7 @@ import { EndpointExample } from "@fern-api/openapi-ir-sdk"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export function getFernExamples(operationObject: OpenAPIV3.OperationObject): EndpointExample[] { return getExtension(operationObject, FernOpenAPIExtension.EXAMPLES) ?? []; diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernResolutions.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernResolutions.ts index 1b928038160..050e936d82a 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernResolutions.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernResolutions.ts @@ -1,6 +1,6 @@ import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export interface FernResolutionSchema { name: string; diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernStreamingExtension.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernStreamingExtension.ts index 4d414d2ed71..1b8c2de7b41 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernStreamingExtension.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernStreamingExtension.ts @@ -1,6 +1,6 @@ import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; const REQUEST_PREFIX = "$request."; diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernTypeExtension.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernTypeExtension.ts index 96adedf4525..94402f63d91 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernTypeExtension.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getFernTypeExtension.ts @@ -2,8 +2,8 @@ import { assertNever } from "@fern-api/core-utils"; import { LiteralSchemaValue, PrimitiveSchemaValueWithExample, SchemaWithExample } from "@fern-api/openapi-ir-sdk"; import { recursivelyVisitRawTypeReference } from "@fern-api/yaml-schema"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export function getFernTypeExtension({ nameOverride, diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getGlobalHeaders.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getGlobalHeaders.ts index 3d24d743d4c..24be7a98e54 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getGlobalHeaders.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getGlobalHeaders.ts @@ -1,7 +1,7 @@ import { GlobalHeader } from "@fern-api/openapi-ir-sdk"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export function getGlobalHeaders(document: OpenAPIV3.Document): GlobalHeader[] | undefined { return getExtension(document, FernOpenAPIExtension.FERN_GLOBAL_HEADERS); diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getPaginationExtension.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getPaginationExtension.ts index bb2fe30b378..fbf888ca991 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getPaginationExtension.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getPaginationExtension.ts @@ -1,6 +1,6 @@ import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export type FernPaginationExtension = FernPaginationEnabledExtension | FernPaginationConfigExtension; diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getParameterName.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getParameterName.ts index 2af5c02d48b..903fd09e788 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getParameterName.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getParameterName.ts @@ -1,6 +1,6 @@ import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export function getParameterName(parameter: OpenAPIV3.ParameterObject): string | undefined { return getExtension(parameter, FernOpenAPIExtension.PARAMETER_NAME); diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getReadmeCodeSamples.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getReadmeCodeSamples.ts index 896cf70485f..b1b6752b827 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getReadmeCodeSamples.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getReadmeCodeSamples.ts @@ -1,7 +1,7 @@ import { isPlainObject } from "@fern-api/core-utils"; import { CustomCodeSample } from "@fern-api/openapi-ir-sdk"; import { OpenAPIV3 } from "openapi-types"; -import { getExtension } from "./getExtension"; +import { getExtension } from "../../../getExtension"; import { ReadmeOpenAPIExtension } from "./readmeExtensions"; // https://docs.readme.com/main/docs/openapi-extensions#custom-code-samples diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getSecuritySchemeNameAndEnvvars.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getSecuritySchemeNameAndEnvvars.ts index 3f1b4878db5..b1221ca805d 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getSecuritySchemeNameAndEnvvars.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getSecuritySchemeNameAndEnvvars.ts @@ -1,6 +1,6 @@ import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export interface SecuritySchemeNames { name?: string; diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getVariableDefinitions.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getVariableDefinitions.ts index 6574677fb20..c451db430e1 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getVariableDefinitions.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getVariableDefinitions.ts @@ -1,8 +1,8 @@ import { PrimitiveSchema, PrimitiveSchemaValue } from "@fern-api/openapi-ir-sdk"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { getGeneratedTypeName } from "../../../schema/utils/getSchemaName"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export function getVariableDefinitions(document: OpenAPIV3.Document): Record { const variables = getExtension>( diff --git a/packages/cli/openapi-parser/src/openapi/v3/extensions/getVariableReference.ts b/packages/cli/openapi-parser/src/openapi/v3/extensions/getVariableReference.ts index 66d21beb3e4..65b024be425 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/extensions/getVariableReference.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/extensions/getVariableReference.ts @@ -1,6 +1,6 @@ import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../../getExtension"; import { FernOpenAPIExtension } from "./fernExtensions"; -import { getExtension } from "./getExtension"; export function getVariableReference(parameter: OpenAPIV3.ParameterObject): string | undefined { return getExtension(parameter, FernOpenAPIExtension.SDK_VARIABLE); diff --git a/packages/cli/openapi-parser/src/openapi/v3/generateIr.ts b/packages/cli/openapi-parser/src/openapi/v3/generateIr.ts index f23e147474c..e72eba1f67e 100644 --- a/packages/cli/openapi-parser/src/openapi/v3/generateIr.ts +++ b/packages/cli/openapi-parser/src/openapi/v3/generateIr.ts @@ -13,6 +13,7 @@ import { } from "@fern-api/openapi-ir-sdk"; import { TaskContext } from "@fern-api/task-context"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../../getExtension"; import { convertSchema } from "../../schema/convertSchemas"; import { convertSchemaWithExampleToSchema } from "../../schema/utils/convertSchemaWithExampleToSchema"; import { isReferenceObject } from "../../schema/utils/isReferenceObject"; @@ -23,7 +24,6 @@ import { convertServer } from "./converters/convertServer"; import { ERROR_NAMES } from "./converters/convertToHttpError"; import { ExampleEndpointFactory } from "./converters/ExampleEndpointFactory"; import { FernOpenAPIExtension } from "./extensions/fernExtensions"; -import { getExtension } from "./extensions/getExtension"; import { getGlobalHeaders } from "./extensions/getGlobalHeaders"; import { getVariableDefinitions } from "./extensions/getVariableDefinitions"; import { OpenAPIV3ParserContext } from "./OpenAPIV3ParserContext"; diff --git a/packages/cli/openapi-parser/src/schema/convertObject.ts b/packages/cli/openapi-parser/src/schema/convertObject.ts index 7f757dd52e6..93f4633bf7e 100644 --- a/packages/cli/openapi-parser/src/schema/convertObject.ts +++ b/packages/cli/openapi-parser/src/schema/convertObject.ts @@ -9,8 +9,8 @@ import { SdkGroupName } from "@fern-api/openapi-ir-sdk"; import { OpenAPIV3 } from "openapi-types"; +import { getExtension } from "../getExtension"; import { FernOpenAPIExtension } from "../openapi/v3/extensions/fernExtensions"; -import { getExtension } from "../openapi/v3/extensions/getExtension"; import { convertSchema, convertToReferencedSchema, getSchemaIdFromReference } from "./convertSchemas"; import { SchemaParserContext } from "./SchemaParserContext"; import { getGeneratedPropertyName } from "./utils/getSchemaName"; diff --git a/packages/cli/openapi-parser/src/schema/convertSchemas.ts b/packages/cli/openapi-parser/src/schema/convertSchemas.ts index 739ae03e7a9..ba7a28afe1d 100644 --- a/packages/cli/openapi-parser/src/schema/convertSchemas.ts +++ b/packages/cli/openapi-parser/src/schema/convertSchemas.ts @@ -8,10 +8,9 @@ import { } from "@fern-api/openapi-ir-sdk"; import { isEqual } from "lodash-es"; import { OpenAPIV3 } from "openapi-types"; -import { getExampleAsBoolean, getExampleAsNumber, getExamplesString } from "./examples/getExample"; +import { getExtension } from "../getExtension"; import { OpenAPIExtension } from "../openapi/v3/extensions/extensions"; import { FernOpenAPIExtension } from "../openapi/v3/extensions/fernExtensions"; -import { getExtension } from "../openapi/v3/extensions/getExtension"; import { getFernEnum } from "../openapi/v3/extensions/getFernEnum"; import { getFernTypeExtension } from "../openapi/v3/extensions/getFernTypeExtension"; import { convertAdditionalProperties, wrapMap } from "./convertAdditionalProperties"; @@ -22,6 +21,7 @@ import { convertLiteral } from "./convertLiteral"; import { convertNumber } from "./convertNumber"; import { convertObject } from "./convertObject"; import { convertUndiscriminatedOneOf } from "./convertUndiscriminatedOneOf"; +import { getExampleAsBoolean, getExampleAsNumber, getExamplesString } from "./examples/getExample"; import { SchemaParserContext } from "./SchemaParserContext"; import { getGeneratedTypeName } from "./utils/getSchemaName"; import { isReferenceObject } from "./utils/isReferenceObject";