A code generator from JSON schema and Nexus service definitions.
To generate code using the included sample schemas for TypeScript, run the following command:
bun ./index.ts --lang ts samples/schemas/separate/* > services.tsAlternatively, generate from a single file that combines Nexus and JSON schemas:
bun ./index.ts --lang ts samples/schemas/combined/services.yml > services.tsThis will process all schemas in the samples/schemas/ directory and output the generated TypeScript code to the
console.
In this example, services.ts will contain type definitions as well as Nexus service and operation definitions, you
should see the following at the end of the generated file:
export const UserService = nexus.service("directory.UserService", {
  getUser: nexus.operation<GetPersonRequest, GetPersonResponse>({
    name: "Get User",
  }),
});- 
Sample TypeScript output can be found here.
 - 
Sample Python output can be found here.
 - 
Sample Go + Temporal output can be found here.
 - 
The
--langoption specifies the output language (e.g.,tsfor TypeScript). - 
The paths following the language are the schema files to process. You can specify individual files or use a glob pattern like
samples/schemas/*. 
The code generator supports plugins to generate additional custom code. For example, there's a Temporal plugin included in this repo, that generates a Go Temporal Workflow Nexus client.
To run the command with plugins use:
bun ./index.ts --lang go --plugin ./src/plugins/temporal/index.ts samples/schemas/combined/services.yml
See: https://bun.sh/docs/installation
bun installbun run index.ts