Skip to content

Commit

Permalink
Merge branch 'dd/getDocsForUrl-lambda' of github.com:fern-api/fern-pl…
Browse files Browse the repository at this point in the history
…atform into dd/getdocsforurl-lambda
  • Loading branch information
dubwub committed Jan 13, 2025
2 parents 184081a + 3ecb81a commit d82e030
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/parsers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"dependencies": {
"@fern-api/logger": "0.4.24-rc1",
"@fern-api/ui-core-utils": "workspace:*",
"@open-rpc/meta-schema": "^1.14.9",
"es-toolkit": "^1.24.0",
"openapi-types": "^12.1.3",
"ts-essentials": "^10.0.1",
Expand Down
60 changes: 60 additions & 0 deletions packages/parsers/src/openrpc/BaseOpenApiV3_1Converter.node.ts
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,
});
}
}
}
1 change: 1 addition & 0 deletions packages/parsers/src/openrpc/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./BaseOpenApiV3_1Converter.node";
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d82e030

Please sign in to comment.