Skip to content

[TFgen] Added a parser to load the OAS#3851

Merged
Supam merged 5 commits into
generator-v2from
thibault.viennot/generator-v2/parser
Jun 4, 2026
Merged

[TFgen] Added a parser to load the OAS#3851
Supam merged 5 commits into
generator-v2from
thibault.viennot/generator-v2/parser

Conversation

@Supam
Copy link
Copy Markdown
Member

@Supam Supam commented Jun 2, 2026

Changes

Adds the OpenAPI spec loader for the v2 generator. parser.LoadSpec parses the Datadog OAS via libopenapi v3 into the internal model.Spec and model.Operation, enumerating every operation sorted by (path, method) so generated output is deterministic across runs.

Cycle detection lives in the same file walk: LoadSpec resolves the component schema graph and fails fast on an unresolvable spec:

  • a circular $ref returns a typed *RefCycleError naming the offending ref, and
  • a $ref chain deeper than --max-depth (default 8) returns a depth error.

The --max-depth flag is wired through the generate command.

Test Plan

New coverage: deterministic-ordering regression, typed cycle error (self / indirect / allOf / additionalProperties / array-items), --max-depth bound, and the cycleWalker state machine.

❮ make tfgen-test
cd .generator-v2 && go test ./internal/... ./cmd/tfgen/... -race -cover
ok    generator/internal/cli        1.618s  coverage: 77.1% of statements
ok    generator/internal/model      2.099s  coverage: 100.0% of statements
ok    generator/internal/parser     1.891s  coverage: 86.2% of statements
      generator/cmd/tfgen                   coverage: 0.0% of statements

Copy link
Copy Markdown
Member Author

Supam commented Jun 2, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Supam Supam force-pushed the thibault.viennot/generator-v2/parser branch from 7ed2d25 to 20016cd Compare June 2, 2026 13:09
@Supam Supam force-pushed the thibault.viennot/generator-v2/translator branch from 3e85006 to 1b6e7b3 Compare June 2, 2026 13:09
@Supam Supam mentioned this pull request Jun 2, 2026
@Supam Supam force-pushed the thibault.viennot/generator-v2/parser branch 2 times, most recently from 14c59b8 to d5f2edb Compare June 2, 2026 13:44
@j10czar j10czar force-pushed the thibault.viennot/generator-v2/translator branch from 1b6e7b3 to 973ef8f Compare June 2, 2026 15:24
@j10czar j10czar force-pushed the thibault.viennot/generator-v2/parser branch from 8be55d8 to 0aec356 Compare June 2, 2026 15:24
@Supam Supam force-pushed the thibault.viennot/generator-v2/parser branch from eb53a77 to 2aa560f Compare June 3, 2026 08:46
@Supam Supam marked this pull request as ready for review June 3, 2026 09:13
@Supam Supam requested a review from a team as a code owner June 3, 2026 09:13
@datadog-datadog-prod-us1-2

This comment has been minimized.

@Supam Supam force-pushed the thibault.viennot/generator-v2/translator branch from 973ef8f to 5208b2a Compare June 3, 2026 09:56
@Supam Supam force-pushed the thibault.viennot/generator-v2/parser branch 2 times, most recently from 301490f to 5eb0064 Compare June 3, 2026 12:23
@Supam Supam force-pushed the thibault.viennot/generator-v2/translator branch from 5208b2a to 22ee648 Compare June 3, 2026 12:23
Base automatically changed from thibault.viennot/generator-v2/translator to generator-v2 June 3, 2026 12:26
@Supam Supam force-pushed the thibault.viennot/generator-v2/parser branch from 5eb0064 to bf3cc22 Compare June 3, 2026 12:30
Copy link
Copy Markdown

@j10czar j10czar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Supam added 3 commits June 4, 2026 08:41
LoadSpec now resolves the component schema graph before enumerating:
a circular $ref returns a typed *RefCycleError naming the offending
ref, and expansion past --max-depth returns a depth error.

The --max-depth flag is now wired through the generate command.
- Added better fixture coverage for allOf / anyOf
- Added custom error for when max depth is reached in cycles.go
@j10czar j10czar force-pushed the thibault.viennot/generator-v2/parser branch from cd57259 to b98b820 Compare June 4, 2026 12:42
@Supam Supam merged commit bc3a698 into generator-v2 Jun 4, 2026
7 of 8 checks passed
@Supam Supam deleted the thibault.viennot/generator-v2/parser branch June 4, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants