-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dd/getDocsForUrl-lambda' of github.com:fern-api/fern-pl…
…atform into dd/getdocsforurl-lambda
- Loading branch information
Showing
4 changed files
with
70 additions
and
0 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
60 changes: 60 additions & 0 deletions
60
packages/parsers/src/openrpc/BaseOpenApiV3_1Converter.node.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,60 @@ | ||
import type { OpenrpcDocument } from "@open-rpc/meta-schema"; | ||
import { | ||
BaseApiConverterNode, | ||
BaseApiConverterNodeContext, | ||
} from "../BaseApiConverter.node"; | ||
|
||
export abstract class BaseOpenrpc_ConverterNodeContext extends BaseApiConverterNodeContext { | ||
public abstract document: OpenrpcDocument; | ||
} | ||
|
||
export type BaseOpenrpc_ConverterNodeConstructorArgs<Input> = { | ||
input: Input; | ||
context: BaseOpenrpc_ConverterNodeContext; | ||
readonly accessPath: string[]; | ||
readonly pathId: string; | ||
}; | ||
|
||
export abstract class BaseOpenApiV3_1ConverterNode< | ||
Input, | ||
Output, | ||
> extends BaseApiConverterNode<Input, Output> { | ||
protected override readonly context: BaseOpenrpc_ConverterNodeContext; | ||
protected readonly accessPath: string[]; | ||
protected readonly pathId: string; | ||
|
||
constructor({ | ||
input, | ||
context, | ||
accessPath, | ||
pathId, | ||
}: BaseOpenrpc_ConverterNodeConstructorArgs<Input>) { | ||
super(input, context); | ||
|
||
this.context = context; | ||
this.accessPath = [...accessPath]; | ||
this.pathId = pathId; | ||
|
||
if ( | ||
this.pathId && | ||
this.pathId !== this.accessPath[this.accessPath.length - 1] | ||
) { | ||
this.accessPath.push(this.pathId); | ||
context.logger.debug(`Processing #/${this.accessPath.join("/")}`); | ||
} | ||
} | ||
|
||
abstract parse(...additionalArgs: unknown[]): void; | ||
|
||
safeParse(...additionalArgs: unknown[]): void { | ||
try { | ||
this.parse(...additionalArgs); | ||
} catch { | ||
this.context.errors.error({ | ||
message: | ||
"Error converting node. Please contact support if the error persists", | ||
path: this.accessPath, | ||
}); | ||
} | ||
} | ||
} |
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 @@ | ||
export * from "./BaseOpenApiV3_1Converter.node"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.