Orval

Introduction

  • orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats.

Configuration

orval.config.js
const { defineConfig } = require("orval");
module.exports = defineConfig({
  "famchest-api": {
    input: "https://dty6p2hiuf.us-east-1.awsapprunner.com/api-json",
    output: {
      mode: "tags-split",
      // generate type into a singgle file
      target: "./src/api/famchest.ts",
      // generate type into multiple files on same directory
      // schemas: "./lib/model",
      client: "react-query",
      prettier: true,
      // override the react-query fetching function
      override: {
        mutator: {
          path: "./src/api/fetcher.ts",
          name: "fetcher",
        },
      },
    },
  },
});

Generated File

  • Type

  • React query hooks

Last updated

Was this helpful?