Skip to main content

Import

Convert an OpenAPI document into an OMG project. The input is a local YAML or JSON file with an openapi field.

Usage​

omg import <input> [options]
ArgumentDescription
inputPath to the OpenAPI YAML or JSON file

Options​

OptionDefaultDescription
-o, --output <directory>Current working directoryDirectory for generated files
--inlineOffInline referenced schemas instead of using named references
--dry-runOffList the files that would be generated without writing them
--no-partialsPartial extraction enabledKeep repeated parameter and response definitions in endpoint files
--partial-threshold <n>3Minimum occurrences before a repeated definition is extracted into a partial
-h, --help—Show command help

Examples​

# Import into a separate directory
omg import openapi.yaml --output my-api/

# Preview conversion and output paths
omg import openapi.json --output my-api/ --dry-run

# Inline referenced schemas
omg import openapi.yaml --output my-api/ --inline

# Keep repeated definitions in endpoint files
omg import openapi.yaml --output my-api/ --no-partials

# Extract definitions repeated at least twice
omg import openapi.yaml --output my-api/ --partial-threshold 2

Generated files​

PathContents
api.omg.mdRoot API definition
endpoints/**/*.omg.mdEndpoint definitions
types/*.omg.mdNamed schema definitions, when needed
partials/**/*.omg.mdExtracted shared header/query parameters and repeated responses, when enabled and detected

Generated files with existing names are overwritten. --dry-run performs conversion and lists output paths without creating directories or writing files. Conversion warnings are printed in both modes.

The generated files can be checked with omg lint and compiled with omg build:

omg lint my-api/
omg build my-api/api.omg.md --output openapi.yaml