Skip to Content
vovk generate

vovk generate

Quick CLI Ref
$ npx vovk generate --help Usage: vovk generate|g [options] Generate RPC client from schema Options: --composed-only generate only composed client even if segmented client is enabled --out, --composed-out <path> path to output directory for composed client --from, --composed-from <templates...> client template names for composed client --include, --composed-include-segments <segments...> include segments in composed client --exclude, --composed-exclude-segments <segments...> exclude segments in composed client --segmented-only generate only segmented client even if composed client is enabled --segmented-out <path> path to output directory for segmented client --segmented-from <templates...> client template names for segmented client --segmented-include-segments <segments...> include segments in segmented client --segmented-exclude-segments <segments...> exclude segments in segmented client --prettify prettify output files --force replace files at the output paths that vovk-cli did not generate --schema, --schema-path <path> path to schema folder (default: ./.vovk-schema) --config, --config-path <config> path to config file --origin <url> set the origin URL for the generated client --watch [s] watch for changes in schema or openapi spec and regenerate client; accepts a number in seconds to throttle the watcher or make an HTTP request to the OpenAPI spec URLs --openapi, --openapi-spec <openapi_path_or_urls...> use OpenAPI mixins for client generation --openapi-module-name, --openapi-get-module-name <names...> module name strategies corresponding to the index of --openapi option --openapi-method-name, --openapi-get-method-name <names...> method name strategies corresponding to the index of --openapi option --openapi-root-url <urls...> root URLs corresponding to the index of --openapi option --openapi-mixin-name <names...> mixin names corresponding to the index of --openapi option --openapi-fallback <paths...> save OpenAPI spec corresponding to the index of --openapi option to a local file and use it as a fallback if URL is not available --log-level <level> set the log level -h, --help display help for command

vovk generate creates TypeScript, Rust and Python clients from the schema files and from the OpenAPI mixins of the config. It uses these config options:

See the config page.

In a Next.js project, a segment whose schema file remains after its route file is gone is left out of the client, with a warning. Delete the schema file when you remove a segment. A schema folder given with --schema-path, such as that of another project, is used as it is, unless it’s the schemaOutDir folder.

Available Flags

Composed Client Flags

  • --composed-only — generates only the composed client, even if the segmented client is enabled.
  • --out, --composed-out <path> — overrides composedClient.outDir.
  • --from, --composed-from <templates...> — overrides composedClient.fromTemplates.
  • --include, --composed-include-segments <segments...> — overrides composedClient.includeSegments.
  • --exclude, --composed-exclude-segments <segments...> — overrides composedClient.excludeSegments.

Segmented Client Flags

  • --segmented-only — generates only the segmented client, even if the composed client is enabled.
  • --segmented-out <path> — overrides segmentedClient.outDir.
  • --segmented-from <templates...> — overrides segmentedClient.fromTemplates.
  • --segmented-include-segments <segments...> — overrides segmentedClient.includeSegments.
  • --segmented-exclude-segments <segments...> — overrides segmentedClient.excludeSegments.

OpenAPI mixin Flags

Mixins add the APIs of one or more OpenAPI specs to the client. See OpenAPI mixins.

  • --openapi, --openapi-spec <openapi_path_or_urls...> — one or more OpenAPI specs, as local paths or URLs. A URL is fetched with HTTP GET. Mirrors outputConfig.segments.mixinName.openAPIMixin.source.url (remote) or .source.file (local).
  • --openapi-module-name, --openapi-get-module-name <names...> — module names, matched by index to --openapi. Mirrors outputConfig.segments.mixinName.openAPIMixin.getModuleName. Without it, a module is named after its mixin (--openapi-mixin-name petstore gives petstore), and mixins without a name give api, api2, …
  • --openapi-method-name, --openapi-get-method-name <names...> — method names, matched by index to --openapi. Mirrors outputConfig.segments.mixinName.openAPIMixin.getMethodName.
  • --openapi-root-url <urls...> — root URLs, matched by index to --openapi. Mirrors outputConfig.segments.mixinName.openAPIMixin.apiRoot.
  • --openapi-mixin-name <names...> — mixin names, matched by index to --openapi; mixin, mixin2, … by default. In the config, the name is the key in outputConfig.segments and the pseudo-segment name of the mixin.
  • --openapi-fallback <paths...> — saves the OpenAPI specs to these paths and uses them when the URL is unavailable. The paths match --openapi by index.
  • --watch [s] — generates the client on start, then again on each change of the schema, the OpenAPI spec, the config or package.json. Takes a throttle interval in seconds. A remote spec is requested every s seconds; a changed local file counts once it has kept the same size for 300 ms.

Other Flags

  • --prettify — formats the output files with Prettier . Mirrors composedClient.prettifyClient and segmentedClient.prettifyClient.
  • --force — replaces files at the output paths that vovk-cli did not generate. Without it, the command writes nothing and names those files. A file counts as generated when its first line is the Generated by vovk-cli banner; a JSON file, which can’t hold one, when it sits next to a file with the banner. Files that a template copies as they are, or renders without the banner, are replaced either way.
  • --schema, --schema-path <path> — overrides the schema folder, schemaOutDir.
  • --config, --config-path <config> — overrides the config file path. By default, the CLI checks every supported file name and warns if it finds more than one.
  • --origin <url> — overrides outputConfig.origin.
  • --log-level <level> — the log level: trace, debug, info, warn, error, silent (default: info).
  • -h, --help — shows help.
Last updated on