— MIT Licensed — YAML Generator

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.

$npm install @powerduck/workspace-yaml
workspace.yamlOpenAPI YAMLParse & GenerateType-Safe
Quick Start

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);
Features

Workspace configuration, automated

Generate valid PowerDuck workspace files without hand-writing YAML.

02

OpenAPI YAML Generator

createOpenApiYaml() builds an OpenAPI 3.2 YAML document from structured path and operation data. Consistent formatting, no hand-editing.

03

One-Call Setup

createWorkspaceWithApi() generates both files together — workspace YAML and the referenced OpenAPI spec — ready to drop into a project.

04

Parse & Validate

parseWorkspaceYaml() reads existing workspace files into typed WorkspaceConfig objects. Errors are thrown as WorkspaceYamlError with typed codes.

05

Type-Safe Options

All generator options are fully typed: CreateWorkspaceOptions, CreateOpenApiOptions, CreateWorkspaceWithApiOptions. IDE autocompletion out of the box.

06

Error Types

WorkspaceYamlError with WorkspaceYamlErrorCode enumerates specific failure modes: invalid YAML, missing required fields, unsupported options.

API Reference

Core functions

functioncreateWorkspaceYaml(options)Generate a workspace.yaml string
ParameterTypeDescription
options.namestringWorkspace display name
options.versionstringWorkspace version
options.apisobject[]API entries with name, spec path, baseUrl
Returns
string — formatted YAML
functioncreateOpenApiYaml(options)Generate an OpenAPI YAML string
ParameterTypeDescription
options.titlestringAPI title
options.versionstringAPI version
options.pathsobjectOpenAPI paths object
Returns
string — formatted OpenAPI YAML
functioncreateWorkspaceWithApi(options)Generate both workspace and OpenAPI YAML
Returns
WorkspaceWithApiResult { workspaceYaml: string; openApiYaml: string }
functionparseWorkspaceYaml(yaml)Parse workspace YAML into a typed config object
Returns
WorkspaceConfig — typed workspace configuration
classWorkspaceYamlErrorTyped error for YAML generation/parsing failures

Properties: code (WorkspaceYamlErrorCode), message. Use for structured error handling in tooling.

4
Core Functions
2
YAML Formats
0.2.3
Current Version
MIT
License