Generate PowerDuck Workspace YAML
Programmatically generate valid workspace.yaml and OpenAPI YAML files from structured configuration. Parse existing workspace YAML, validate the schema, and serialize back with proper formatting.
Generate in one call
import { createWorkspaceYaml } from "@powerduck/workspace-yaml"; const yaml = createWorkspaceYaml({ name: "My API Workspace", version: "1.0.0", apis: [{ name: "Users API", spec: "./openapi.yaml", baseUrl: "https://api.example.com", }], }); console.log(yaml);
Workspace configuration, automated
Generate valid PowerDuck workspace files without hand-writing YAML.
Workspace YAML Generator
createWorkspaceYaml() produces a properly formatted workspace.yaml with API entries, server URLs, and authentication settings.
OpenAPI YAML Generator
createOpenApiYaml() builds an OpenAPI 3.2 YAML document from structured path and operation data. Consistent formatting, no hand-editing.
One-Call Setup
createWorkspaceWithApi() generates both files together — workspace YAML and the referenced OpenAPI spec — ready to drop into a project.
Parse & Validate
parseWorkspaceYaml() reads existing workspace files into typed WorkspaceConfig objects. Errors are thrown as WorkspaceYamlError with typed codes.
Type-Safe Options
All generator options are fully typed: CreateWorkspaceOptions, CreateOpenApiOptions, CreateWorkspaceWithApiOptions. IDE autocompletion out of the box.
Error Types
WorkspaceYamlError with WorkspaceYamlErrorCode enumerates specific failure modes: invalid YAML, missing required fields, unsupported options.
Core functions
| Parameter | Type | Description |
|---|---|---|
| options.name | string | Workspace display name |
| options.version | string | Workspace version |
| options.apis | object[] | API entries with name, spec path, baseUrl |
string — formatted YAML
| Parameter | Type | Description |
|---|---|---|
| options.title | string | API title |
| options.version | string | API version |
| options.paths | object | OpenAPI paths object |
string — formatted OpenAPI YAML
WorkspaceWithApiResult { workspaceYaml: string; openApiYaml: string }WorkspaceConfig — typed workspace configuration
Properties: code (WorkspaceYamlErrorCode), message. Use for structured error handling in tooling.