-
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.
chore(openrpc): bump package and setup publishing (#2005)
- Loading branch information
Showing
5 changed files
with
48 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./ErrorCollector"; | ||
export * from "./openapi"; | ||
export * from "./openrpc"; |
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
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
36
packages/parsers/src/openrpc/__test__/createMockContext.util.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 |
---|---|---|
@@ -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, | ||
}, | ||
}; | ||
}); | ||
} |