Add constructive Rapid OpenAPI request-body test generation#1
Conversation
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/test_generator/domain/allof_allof_merge_test.go (1)
379-397: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winTest doesn't exercise its stated "injected child parse fails" scenario.
{"allOf":[{},{}]}uses two empty object items.validateAllOfItemrejects an empty allOf item schema beforedc.Parse/the injected mock is ever called, so the returned error comes from schema validation, not from the injected"boom"failure on the second call.callsnever reaches 2, but the test doesn't assert oncalls, so it passes for the wrong reason and leaves the intended rollback-on-child-parse-error path (distinct from the preceding subtest, which already covers a real parser type error) effectively untested.🧪 Proposed fix to actually exercise the injected failure
- raw := json.RawMessage(`{"allOf":[{},{}]}`) + raw := json.RawMessage(`{"allOf":[{"type":"string"},{"type":"string"}]}`) dc := &Context{} calls := 0 dc.parse = func(_ *json.RawMessage) (types.Domain, error) { calls++ if calls == 2 { return nil, errors.New("boom") } return &StringDomain{}, nil } got, err := dc.Parse(&raw) require.Error(t, err) require.Nil(t, got) require.Empty(t, dc.domainStore) + require.Equal(t, 2, calls)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/test_generator/domain/allof_allof_merge_test.go` around lines 379 - 397, The subtest in Context.Parse is not reaching the injected child parse failure because the allOf payload uses empty object items that fail validateAllOfItem before the mocked parse is called. Change the test setup so the allOf items are valid enough to pass schema validation, then keep the injected dc.parse failure on the second call and assert the expected rollback behavior via dc.domainStore plus the call count if needed. This ensures the “injected child parse fails no partial store commit” case actually exercises the intended path in Context.Parse and validateAllOfItem.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@pkg/test_generator/domain/allof_allof_merge_test.go`:
- Around line 379-397: The subtest in Context.Parse is not reaching the injected
child parse failure because the allOf payload uses empty object items that fail
validateAllOfItem before the mocked parse is called. Change the test setup so
the allOf items are valid enough to pass schema validation, then keep the
injected dc.parse failure on the second call and assert the expected rollback
behavior via dc.domainStore plus the call count if needed. This ensures the
“injected child parse fails no partial store commit” case actually exercises the
intended path in Context.Parse and validateAllOfItem.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 59fba323-d5ed-4bcd-b0f1-d2d9c06e90c6
📒 Files selected for processing (42)
pkg/test_generator/domain/allOf_domain.gopkg/test_generator/domain/allOf_parse_test.gopkg/test_generator/domain/allof_allof_merge_test.gopkg/test_generator/domain/allof_merge_additional_plan_test.gopkg/test_generator/domain/array_allof_merge_test.gopkg/test_generator/domain/array_domain.gopkg/test_generator/domain/array_domain_test.gopkg/test_generator/domain/array_parse_test.gopkg/test_generator/domain/bool_allof_merge_test.gopkg/test_generator/domain/bool_domain.gopkg/test_generator/domain/bool_parse_test.gopkg/test_generator/domain/coverage_gap_test.gopkg/test_generator/domain/domain.gopkg/test_generator/domain/domain_hash_test.gopkg/test_generator/domain/domain_test.gopkg/test_generator/domain/domain_types_test.gopkg/test_generator/domain/enum.gopkg/test_generator/domain/enum_test.gopkg/test_generator/domain/enum_value_validation_test.gopkg/test_generator/domain/hash.gopkg/test_generator/domain/hash_test.gopkg/test_generator/domain/number_allof_merge_test.gopkg/test_generator/domain/number_domain.gopkg/test_generator/domain/number_parse_test.gopkg/test_generator/domain/object_allof_merge_test.gopkg/test_generator/domain/object_domain.gopkg/test_generator/domain/object_domain_test.gopkg/test_generator/domain/string_allof_merge_test.gopkg/test_generator/domain/string_domain.gopkg/test_generator/domain/string_domain_test.gopkg/test_generator/domain/string_parse_test.gopkg/test_generator/jsonrefs/jsonrefs.gopkg/test_generator/jsonrefs/jsonrefs_test.gopkg/test_generator/openapi.gopkg/test_generator/openapi_test.gopkg/test_generator/test_generator.gopkg/test_generator/types/enum.gopkg/test_generator/types/enum_test.gopkg/test_generator/types/string_constraints.gopkg/test_generator/types/string_constraints_test.gopkg/test_generator/types/types.gopkg/test_generator/utils.go
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.pi/skills/codebase-design/DEEPENING.md:
- Around line 34-37: Revise the testing guidance around “interface is the test
surface” to prohibit deleting existing shallow-module tests until equivalent
behavioral coverage, including edge cases and invariants, exists at the deepened
module’s interface. Preserve the recommendation that interface tests are primary
and assert observable outcomes rather than internal state.
In @.pi/skills/codebase-design/SKILL.md:
- Around line 34-41: Add the text language identifier to both fenced ASCII
diagram blocks in SKILL.md, including the blocks around the “Small Interface”
and corresponding later diagram, by changing each opening fence to specify text
while preserving their contents.
In @.pi/skills/improve-codebase-architecture/HTML-REPORT.md:
- Line 16: Update the Mermaid initialization configuration to use securityLevel
"strict" instead of "loose" in mermaid.initialize; retain the existing
startOnLoad and theme settings, and only choose "sandbox" if the generated
report requires interactivity.
In @.pi/skills/improve-codebase-architecture/SKILL.md:
- Around line 34-36: Resolve the contradiction in the report-generation
instructions: either embed Tailwind and Mermaid assets directly in the generated
HTML, or explicitly state that the output requires network access and document
the trust and privacy implications of loading third-party CDN scripts. Update
the self-contained HTML guidance accordingly while preserving the existing
visualisation requirements.
- Around line 20-22: Update the initial workflow in the skill instructions to
handle a missing CONTEXT.md before requiring it to be read: either create the
file before Step 1 or explicitly continue using repository terminology when it
is absent. Ensure the subsequent exploration with the Explore agent remains
reachable in repositories without CONTEXT.md, while preserving the existing
ADR-reading guidance.
In `@AGENTS.md`:
- Line 17: Update the OpenAPI 3.0.3 description in AGENTS.md to identify it as
an extended subset of JSON Schema rather than a superset, avoiding wording that
suggests unsupported JSON Schema features are valid.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: de46111c-bffc-44d6-b444-38950a06e20e
📒 Files selected for processing (6)
.pi/skills/codebase-design/DEEPENING.md.pi/skills/codebase-design/DESIGN-IT-TWICE.md.pi/skills/codebase-design/SKILL.md.pi/skills/improve-codebase-architecture/HTML-REPORT.md.pi/skills/improve-codebase-architecture/SKILL.mdAGENTS.md
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/test_generator/internal/jsonvalue/value.go (1)
1-717: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winRestore the missing
testgenerator.GenerateValidAPI
pkg/test_generator/test_generator.goexportsCheckJSONRequestBody, butpkg/generate/templates/models_test.go.tmplstill emitstestgenerator.GenerateValidandtestgenerator.GenerateInvalid. Update the template or add compatibility wrappers so generated downstream tests compile.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/test_generator/internal/jsonvalue/value.go` around lines 1 - 717, Restore the exported testgenerator.GenerateValid API expected by generated tests, alongside GenerateInvalid. Update the relevant generation template or add compatibility wrappers around the existing JSON generation behavior so pkg/generate/templates/models_test.go.tmpl output compiles without changing its calls.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/test_generator/internal/jsonvalue/value.go`:
- Around line 128-138: In ParseNumber, simplify the magnitude calculation by
calling Abs directly with exponent instead of creating an intermediate copy,
reducing the expression to a single big.Int allocation while preserving the
existing comparison and parsing behavior.
In `@pkg/test_generator/test_generator.go`:
- Around line 39-57: The new CheckJSONRequestBody API is incompatible with
existing GenerateValid and GenerateInvalid callers. Either retain compatibility
wrappers for both public methods, or update
pkg/generate/templates/models_test.go.tmpl and regenerate the consumer tests to
use CheckJSONRequestBody, ensuring pkg/decode/example/models_test.go and
pkg/decode/example_gen/models_test.go compile.
---
Outside diff comments:
In `@pkg/test_generator/internal/jsonvalue/value.go`:
- Around line 1-717: Restore the exported testgenerator.GenerateValid API
expected by generated tests, alongside GenerateInvalid. Update the relevant
generation template or add compatibility wrappers around the existing JSON
generation behavior so pkg/generate/templates/models_test.go.tmpl output
compiles without changing its calls.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: f5df0725-d543-4042-8e1e-a6eb73cac895
📒 Files selected for processing (12)
pkg/test_generator/check_test.gopkg/test_generator/internal/jsonvalue/value.gopkg/test_generator/internal/jsonvalue/value_test.gopkg/test_generator/internal/oas/source.gopkg/test_generator/internal/oas/source_test.gopkg/test_generator/internal/suite/compile.gopkg/test_generator/internal/suite/compile_test.gopkg/test_generator/internal/suite/domain.gopkg/test_generator/internal/suite/domain_registry.gopkg/test_generator/openapi_test.gopkg/test_generator/test_generator.gopkg/test_generator/types/enum.go
💤 Files with no reviewable changes (1)
- pkg/test_generator/openapi_test.go
|
@coderabbitai resume\n\n@coderabbitai review |
|
✅ Action performedReviews resumed. Review finished.
|
|
@coderabbitai resume\n\n@coderabbitai review |
|
✅ Action performedReviews resumed. Review finished.
|
|
@coderabbitai resume\n\n@coderabbitai review |
|
✅ Action performedReviews resumed. Review finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/test_generator/internal/suite/case_partitions.go`:
- Around line 165-176: Define one shared named type, such as labeledBound, for
the label-and-integer boundary entries, then update addStringLengthPartitions,
addArrayCountPartitions, and addObjectCountPartitions to use it for both slice
initialization and conditional appends. Preserve each helper’s existing labels
and constraint values while removing the repeated anonymous struct declarations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e2567279-5c30-496c-8b69-ab2aec168860
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (22)
go.modpkg/test_generator/check_test.gopkg/test_generator/internal/jsonvalue/value.gopkg/test_generator/internal/jsonvalue/value_test.gopkg/test_generator/internal/oas/source.gopkg/test_generator/internal/oas/source_test.gopkg/test_generator/internal/suite/case_partitions.gopkg/test_generator/internal/suite/case_planner.gopkg/test_generator/internal/suite/case_planner_test.gopkg/test_generator/internal/suite/case_witnesses.gopkg/test_generator/internal/suite/compile.gopkg/test_generator/internal/suite/compile_allof.gopkg/test_generator/internal/suite/compile_test.gopkg/test_generator/internal/suite/compile_values.gopkg/test_generator/internal/suite/domain.gopkg/test_generator/internal/suite/domain_registry.gopkg/test_generator/internal/suite/intersect.gopkg/test_generator/internal/suite/intersect_test.gopkg/test_generator/internal/suite/rapid_generator.gopkg/test_generator/internal/suite/rapid_generator_test.gopkg/test_generator/libopenapi_validator_integration_test.gopkg/test_generator/test_generator.go
|
@coderabbitai resume\n\n@coderabbitai review |
|
✅ Action performedReviews resumed. Review finished.
|
Overview
Replaces the legacy request-body test generator with constructive, schema-driven Rapid generation. The new pipeline resolves OpenAPI references, compiles canonical multi-kind domains, plans valid and isolated-invalid cases, and generates exact semantic JSON values with independent validator coverage.
This includes optional
typewith type-specific keyword applicability and lazy Schema Object Reference Object resolution that ignores$refsiblings as required by OpenAPI 3.0.3.Closes #2
Closes #3
Summary by CodeRabbit
New Features
Bug Fixes
Documentation