> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# From OpenAPI

> Install an API an OpenAPI 3 spec describes as one CLI, with Python or TypeScript.

An OpenAPI 3 spec's operations become one CLI: each operation is a
subcommand that takes its parameters and body as one flat JSON object.
Every selected operation needs a description; a summary alone is not
enough, and a spec with an operation that has no description is refused
whole.

This installs the `licenses` and `meta` parts of GitHub's published spec,
which need no token:

```yaml workspace.yaml theme={null}
mounts:
  /:
    vfs: ram
clis:
  github:
    cli: openapi
    machine: in_process
    config:
      spec: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json
      base_url: https://api.github.com
      tags: [licenses, meta]
      headers:
        User-Agent: my-agent
```

`mirage workspace create workspace.yaml` builds it on the server. In code,
read the spec and register it on an existing `ws`:

> [tab] Python
>
> ```python theme={null}
> from mirage import openapi_cli
>
> config = {
>     "spec": "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json",
>     "base_url": "https://api.github.com",
>     "tags": ["licenses", "meta"],
>     "headers": {"User-Agent": "my-agent"},
> }
> ws.register_cli("github", await openapi_cli(config), config)
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> import { openapiCli } from '@struktoai/mirage-node'
>
> const config = {
>   spec: 'https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json',
>   base_url: 'https://api.github.com',
>   tags: ['licenses', 'meta'],
>   headers: { 'User-Agent': 'my-agent' },
> }
> ws.registerCli('github', await openapiCli(config), config)
> ```

The operation with operationId `licenses/get` (`GET /licenses/{license}`,
summary "Get a license") becomes the subcommand `licenses-get`:

```bash theme={null}
github --help
github licenses-get --help
github licenses-get '{"license": "mit"}' | jq -c '{key, name}'
```

With `flags: true` in the config, each subcommand takes flags instead of a
single JSON string: `github licenses-get --license mit` rather than
`github licenses-get '{"license": "mit"}'`. The SDK guides list how each
schema type becomes a flag.

## SDK guides

> [card] [Python](https://docs.mirage.strukto.ai/python/cli/openapi.md)
>
> Spec options, how operations become commands, and what a spec must hold.

> [card] [TypeScript](https://docs.mirage.strukto.ai/typescript/cli/openapi.md)
>
> Spec options, how operations become commands, and what a spec must hold.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.