Codegen Rules

Cross-language governance — validation gates, breaking change policy, output structure, and field exclusions.


codegenRules apply across all language targets. They express governance constraints that generators MUST enforce before and during code emission.

codegenRules:
  validation:
    - rule: no-unnamed-operations
      severity: error
  reconciliation:
    mode: declarative
    ignoreDrift: [status, createdAt]
    immutableFields: [id, region]
  breakingChangePolicy: major-version-bump
  sdkVersioning: semver-manual
  outputStructure: by-tag
  ignoreFields:
    - __debug
    - _internalOnly

Validation Rules

Generators MUST evaluate validation rules against the source OpenAPI spec before emitting code.

  • Rules with severity: error MUST halt generation.
  • Rules with severity: warn SHOULD print a warning but MAY continue.
  • Rules with severity: info are informational only.
codegenRules:
  validation:
    - rule: no-unnamed-operations
      severity: error
      message: "Every operation must have an operationId."
    - rule: required-tags
      severity: error
    - rule: no-inline-schemas
      severity: warn
    - rule: custom
      severity: error
      customRuleUrl: "https://acme.com/rules/no-empty-tags.js"

Built-in Rules

RuleDescription
no-unnamed-operationsEvery operation must have an operationId. Anonymous operations cannot be mapped to SDK methods.
required-tagsEvery operation must have at least one tag for SDK grouping.
no-inline-schemasSchemas must be defined in components/schemas, not inline. Inline schemas cannot be named and may break across regenerations.
required-descriptionsOperations and schemas must have descriptions.
no-deprecated-without-successorDeprecated operations should reference their replacement via x-successor.
no-empty-responsesEvery operation must declare at least one response.
customA custom rule script loaded from customRuleUrl.

Breaking Change Policy

Controls how generators handle breaking changes detected between the current spec and the previous version.

ValueBehavior
major-version-bumpGenerators increment the major version. May include both old and new symbols during a transition period.
deprecate-firstOld symbol is marked deprecated and kept for one release cycle before removal.
warn-onlyGenerators warn but do not modify versioning or symbols.

SDK Versioning Strategy

ValueDescription
semver-from-openapiSDK version is derived from the OpenAPI spec’s info.version field.
semver-manualSDK version is taken from sdk.version in opensdk.yaml.
date-basedSDK version is a date stamp (e.g. 2026.04.01).

Output Structure

Controls how generated files are organized on disk.

ValueDescription
flatAll generated files in a single directory.
by-tagOne directory per OpenAPI tag.
by-resourceOne directory per top-level resource noun.
by-operationOne file per operation.

Global Field Exclusions

Fields in ignoreFields are stripped from all generated models across every language target.

codegenRules:
  ignoreFields:
    - __debug
    - _internalOnly
    - x_internal_id

This is useful for internal or debug fields that appear in your API schema but should never be exposed in public SDKs.