Skip to content

fix(cmd): emit enum values and filter hidden definitions in cue2openapi - #461

Draft
eddie-knight wants to merge 2 commits into
gemaraproj:mainfrom
eddie-knight:fix/cue2openapi-enums-hidden-defs
Draft

fix(cmd): emit enum values and filter hidden definitions in cue2openapi#461
eddie-knight wants to merge 2 commits into
gemaraproj:mainfrom
eddie-knight:fix/cue2openapi-enums-hidden-defs

Conversation

@eddie-knight

@eddie-knight eddie-knight commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Description 🤖

  • Disjunctions of string literals now emit OpenAPI enum values (handles nested chains and *"default" markers).
  • Hidden definitions (#_Name) are omitted from output; refs to them are rewritten to the visible definition they constrain.
  • Hidden struct fields (_name) no longer leak as properties.
  • make test now also runs the cmd/ test suite in CI.

Downstream impact

Although no CUE schemas change, the generated generated/openapi.yaml (published as a release asset and consumed by @gemara/react's type generation) changes shape: 17 schemas gain enum (generated TS types become literal unions instead of string), two $refs move from _MappingStrict/_AssessmentLogStrict to Mapping/AssessmentLog, and two hidden schemas plus two hidden fields disappear from the output.

Schema Changes

Schema Changes Made

  • No schema changes
  • Audit Log schema (auditlog.cue) changes
  • Capability Catalog schema (capabilitycatalog.cue) changes
  • Control Catalog schema (controlcatalog.cue) changes
  • Enforcement Log schema (enforcementlog.cue) changes
  • Evaluation Log schema (evaluationlog.cue) changes
  • Guidance Catalog schema (guidancecatalog.cue) changes
  • Mapping Document schema (mappingdocument.cue) changes
  • Policy Document schema (policy.cue) changes
  • Principle Catalog schema (principlecatalog.cue) changes
  • Risk Catalog schema (riskcatalog.cue) changes
  • Threat Catalog schema (threatcatalog.cue) changes
  • Vector Catalog schema (vectorcatalog.cue) changes
  • Other

Schema Change Details

<!-- If applicable, provide a brief summary or example of schema changes -->

Testing

  • Unit tests added/updated
  • Manual testing performed
  • Test data updated (if applicable)

Related Issues

Reviewer Hints


Self-review checklist

  • This PR has content that was created with AI assistance.
  • I have the experience and knowledge necessary to answer maintainer questions about the content of this PR, without using AI.

- Disjunctions of string literals now emit OpenAPI enum values
  (handles nested chains and *"default" markers).
- Hidden definitions (#_Name) are omitted from output; refs to them
  are rewritten to the visible definition they constrain.
- Hidden struct fields (_name) no longer leak as properties.
- make test now also runs the cmd/ test suite in CI.

Signed-off-by: Eddie Knight <knight@linux.com>
@github-actions github-actions Bot added the fix label Aug 25, 2026
…er tests

- Error out in the pre-pass when a #_ definition does not unify with a
  visible definition, instead of silently leaving it in the output where
  it only surfaced as a confusing leak-check test failure.
- Document that ref rewriting intentionally drops the hidden definition's
  extra constraints, that findBaseIdent ignores attribute-only structs,
  and that CUE default markers are deliberately not emitted as OpenAPI
  defaults.
- Treat only unquoted _name labels as hidden fields; a quoted "_name"
  is an exported CUE field.
- Assert exact enum values (citing their CUE sources), assert the
  rewritten $ref structurally instead of via a loose substring match,
  and add a table test for collectEnumStrings' non-enum fallback.
- Run the test suites with -count=1: they read *.cue schemas at runtime,
  which Go's test cache cannot track.

Signed-off-by: Eddie Knight <knight@linux.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant