CLI Reference
Massimo CLI Reference
Section titled “Massimo CLI Reference”The Massimo CLI (massimo-cli) creates Fastify plugins that expose clients for remote OpenAPI or GraphQL APIs.
Basic Usage
Section titled “Basic Usage”npx massimo-cli [url|file] [options]# or if installed globally:massimo [url|file] [options]Commands
Section titled “Commands”massimo
Section titled “massimo”Generate a client plugin from an OpenAPI or GraphQL schema.
Arguments
Section titled “Arguments”url|file- URL to the API schema or path to a local schema file
Options
Section titled “Options”| Option | Alias | Description | Default |
|---|---|---|---|
--name <name> | -n | Name of the client | Required |
--folder <name> | -f | Name of the plugin folder | Same as --name |
--config <path> | -c | Path to the configuration file | - |
--module <esm|cjs> | Module format (ESM or CommonJS) | Auto-detect | |
--typescript | -t | Generate the client plugin in TypeScript | false |
--frontend | Generate browser-compatible client using fetch | false | |
--language <js|ts> | Language for frontend client | js | |
--full-response | Return full response object instead of just body | false | |
--full-request | Wrap parameters in body, headers, query | false | |
--full | Enable both --full-request and --full-response | false | |
--optional-headers <headers> | Comma-separated headers marked as optional | - | |
--validate-response | Validate response body against schema | false | |
--url-auth-headers <headers> | Auth headers for schema URL (JSON string) | - | |
--types-only | Generate only TypeScript types | false | |
--types-comment | Add comment to generated .d.ts file | false | |
--type-extension | Force TypeScript declaration file extensions | false | |
--with-credentials | Add credentials: 'include' to fetch requests | false | |
--props-optional | Define properties as optional unless required | true | |
--skip-config-update | Skip updating Platformatic/Watt config | true | |
--retry-timeout-ms <ms> | Retry timeout for HTTP requests | - |
Usage Examples
Section titled “Usage Examples”Basic Examples
Section titled “Basic Examples”Generate OpenAPI client:
massimo http://example.com/openapi.json -n myclientGenerate GraphQL client:
massimo http://example.com/graphql -n myclientUse local schema file:
massimo path/to/schema.json -n myclientModule Format Examples
Section titled “Module Format Examples”Generate ESM client:
massimo https://api.example.com/openapi.json --name my-api --module esmGenerate CommonJS client:
massimo https://api.example.com/openapi.json --name my-api --module cjsAuto-detect module format from package.json:
# Detects from "type": "module" in package.jsonmassimo https://api.example.com/openapi.json --name my-apiAdvanced Examples
Section titled “Advanced Examples”TypeScript plugin:
massimo https://api.example.com/openapi.json --name my-api --typescriptFrontend client with TypeScript:
massimo https://api.example.com/openapi.json --frontend --language ts --name my-apiTypes only:
massimo https://api.example.com/openapi.json --types-only --name my-apiForce TypeScript declaration file extensions:
# Generate .d.mts for ESM or .d.cts for CommonJS based on module formatmassimo https://api.example.com/openapi.json --types-only --type-extension --name my-apiFull response/request objects:
massimo https://api.example.com/openapi.json --full --name my-apiWith authentication headers:
massimo https://private-api.com/openapi.json \ --url-auth-headers '{"Authorization":"Bearer TOKEN"}' \ --name private-apiBrowser client with credentials:
massimo https://api.example.com/openapi.json \ --frontend \ --with-credentials \ --name my-apiModule Format Detection
Section titled “Module Format Detection”Massimo automatically detects your project’s module format:
-
ESM (ECMAScript Modules): Generated when your
package.jsoncontains"type": "module"- Output files use
.mjsextension - Uses
import/exportsyntax
- Output files use
-
CommonJS: Generated when
package.jsondoesn’t have"type": "module"or has"type": "commonjs"- Output files use
.cjsextension - Uses
require/module.exportssyntax
- Output files use
-
Override: Use
--module esmor--module cjsto force a specific format
TypeScript Declaration File Extensions
Section titled “TypeScript Declaration File Extensions”When generating TypeScript declaration files, Massimo can intelligently determine the appropriate file extension:
Default Behavior
Section titled “Default Behavior”- TypeScript declaration files are generated with the
.d.tsextension by default
With --type-extension Flag
Section titled “With --type-extension Flag”When you use the --type-extension flag, Massimo generates module-specific TypeScript declaration files:
- ESM Projects: Generates
.d.mtsfiles (TypeScript declaration for ESM modules) - CommonJS Projects: Generates
.d.ctsfiles (TypeScript declaration for CommonJS modules)
Extension Determination Rules
Section titled “Extension Determination Rules”The TypeScript declaration file extension is determined by the following precedence:
- Explicit
--type-extensionflag: Forces generation of module-specific extensions - Module format: Based on
--moduleflag or detected module type from package.json - Parent package.json: Falls back to the
"type"field in the parent package.json
Examples
Section titled “Examples”# Generate .d.mts for ESM projectmassimo https://api.example.com/openapi.json --types-only --type-extension --module esm --name my-api
# Generate .d.cts for CommonJS projectmassimo https://api.example.com/openapi.json --types-only --type-extension --module cjs --name my-api
# Auto-detect and generate appropriate extensionmassimo https://api.example.com/openapi.json --types-only --type-extension --name my-api