Skip to content

Commit

Permalink
chore(openrpc): bump package and setup publishing (#2005)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Jan 14, 2025
1 parent 7783034 commit 3eebf4c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/parsers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fern-api/docs-parsers",
"version": "0.0.29",
"version": "0.0.30",
"repository": {
"type": "git",
"url": "https://github.com/fern-api/fern-platform.git",
Expand Down
1 change: 1 addition & 0 deletions packages/parsers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./ErrorCollector";
export * from "./openapi";
export * from "./openrpc";
11 changes: 3 additions & 8 deletions packages/parsers/src/openrpc/BaseOpenrpcConverter.node.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import type { OpenrpcDocument } from "@open-rpc/meta-schema";
import { BaseApiConverterNode } from "../BaseApiConverter.node";
import { BaseOpenApiV3_1ConverterNodeContext } from "../openapi";

export abstract class BaseOpenrpcConverterNodeContext extends BaseOpenApiV3_1ConverterNodeContext {
public abstract openrpc: OpenrpcDocument;
}
import { OpenrpcContext } from "./OpenrpcContext";

export type BaseOpenrpcConverterNodeConstructorArgs<Input> = {
input: Input;
context: BaseOpenrpcConverterNodeContext;
context: OpenrpcContext;
readonly accessPath: string[];
readonly pathId: string;
};
Expand All @@ -17,7 +12,7 @@ export abstract class BaseOpenrpcConverterNode<
Input,
Output,
> extends BaseApiConverterNode<Input, Output> {
protected override readonly context: BaseOpenrpcConverterNodeContext;
protected override readonly context: OpenrpcContext;
protected readonly accessPath: string[];
protected readonly pathId: string;

Expand Down
34 changes: 34 additions & 0 deletions packages/parsers/src/openrpc/OpenrpcContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { Logger } from "@fern-api/logger";
import { OpenrpcDocument } from "@open-rpc/meta-schema";
import { OpenAPIV3_1 } from "openapi-types";
import { BaseOpenApiV3_1ConverterNodeContext } from "../openapi";

export declare namespace OpenrpcContext {
interface Args {
openrpc: OpenrpcDocument;
logger: Logger;
}
}

export class OpenrpcContext extends BaseOpenApiV3_1ConverterNodeContext {
public openrpc: OpenrpcDocument;
public override logger: Logger;

constructor(args: OpenrpcContext.Args) {
super();
this.openrpc = args.openrpc;
this.logger = args.logger;
}

public get document(): OpenAPIV3_1.Document {
return {
openapi: "3.1.0",
info: {
title: "Mock API",
version: "1.0.0",
},
paths: {},
components: this.openrpc.components,
};
}
}
36 changes: 9 additions & 27 deletions packages/parsers/src/openrpc/__test__/createMockContext.util.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,15 @@
import { OpenrpcDocument } from "@open-rpc/meta-schema";
import { vi } from "vitest";
import { BaseOpenrpcConverterNodeContext } from "../BaseOpenrpcConverter.node";
import { OpenrpcContext } from "../OpenrpcContext";

export function createMockContext(
document?: OpenrpcDocument
): BaseOpenrpcConverterNodeContext {
return {
document: {
openapi: "3.1.0",
info: {
title: "Mock API",
version: "1.0.0",
},
paths: {},
components: document.components,
},
export function createMockContext(document?: OpenrpcDocument): OpenrpcContext {
return new OpenrpcContext({
openrpc: document,
logger: {
info: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
debug: vi.fn(),
log: vi.fn(),
},
errors: {
error: vi.fn(),
warning: vi.fn(),
warnings: [],
errors: [],
log: console.log,
debug: console.debug,
info: console.info,
warn: console.warn,
error: console.error,
},
};
});
}

0 comments on commit 3eebf4c

Please sign in to comment.