Skip to content

test: add parameter serialization matrix and format validation tests#5

Merged
nic-6443 merged 7 commits intomainfrom
feat/p1-fixes
Apr 21, 2026
Merged

test: add parameter serialization matrix and format validation tests#5
nic-6443 merged 7 commits intomainfrom
feat/p1-fixes

Conversation

@jarvis9443
Copy link
Copy Markdown
Contributor

@jarvis9443 jarvis9443 commented Apr 21, 2026

Add conformance test suites for parameter serialization and format validation.

Changes

Parameter serialization matrix (t/conformance/test_param_serialization_matrix.lua)

  • 54 table-driven tests covering style × explode × type combinations
  • Covers query/path/header locations with form/simple/pipeDelimited/spaceDelimited/deepObject styles

Format validation (t/conformance/test_format_validation.lua)

  • 29 tests for uuid, date, date-time, uri, email, ipv4, hostname formats
  • Positive and negative cases for each format
  • Depends on jsonschema v0.9.10 (api7/jsonschema#96)

CI update (.github/workflows/test.yml)

  • Install jsonschema v0.9.10 from released rockspec (replaces git overlay)

Summary by CodeRabbit

  • Tests
    • Added conformance tests validating OpenAPI format handling (uuid, date, date-time, uri, email, ipv4, hostname) with positive and negative cases.
    • Added data-driven conformance tests for parameter serialization across query, path, and header with multiple styles, explode behaviors, and positive/negative scenarios.
  • Chores
    • CI updated to install a specific jsonschema version for test runs.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds two new Lua conformance tests (format validation and parameter serialization matrix) and updates the CI workflow to install a specific jsonschema rockspec before running tests.

Changes

Cohort / File(s) Summary
Conformance: format validation
t/conformance/test_format_validation.lua
New test suite that constructs OpenAPI 3.0 specs per format and asserts request validation for uuid, date, date-time, uri, email, ipv4, and hostname with positive and negative cases; aborts on compile failure.
Conformance: parameter serialization matrix
t/conformance/test_param_serialization_matrix.lua
New data-driven tests that generate specs and requests for query/path/header parameters across style/explode/schema variations; asserts expected validation success/failure, including missing-required-parameter scenarios and type/serialization mismatches.
CI workflow
.github/workflows/test.yml
Changes Lua dependency installation to use a specific api7/jsonschema rockspec/version (installs jsonschema via explicit rockspec URL) instead of the generic luarocks install jsonschema invocation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • nic-6443
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: two new test suites (parameter serialization matrix and format validation) and a CI dependency update.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
E2e Test Quality Review ✅ Passed PR adds comprehensive conformance test suites (54+ parameter serialization and 29 format validation tests) following established E2E patterns with proper error handling and boundary coverage.
Security Check ✅ Passed PR adds test suites with no hardcoded secrets, credentials, or sensitive data. No database operations, auth bypass, cryptographic misconfigurations, or security vulnerabilities detected across all categories.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/p1-fixes

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
t/conformance/test_param_serialization_matrix.lua (1)

11-32: Avoid mutating the caller’s param_def inside make_spec (Line 15).

make_spec currently mutates input state (param_def.required = true), which can create brittle tests as this helper gets reused.

♻️ Suggested refactor
 local function make_spec(param_def, location)
+    local param = cjson.decode(cjson.encode(param_def))
     local path_template
     if location == "path" then
-        path_template = "/test/{" .. param_def.name .. "}"
-        param_def.required = true
+        path_template = "/test/{" .. param.name .. "}"
+        param.required = true
     else
         path_template = "/test"
     end
 
     return cjson.encode({
@@
                 get = {
-                    parameters = { param_def },
+                    parameters = { param },
                     responses = { ["200"] = { description = "OK" } },
                 },
             },
         },
     })
 end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@t/conformance/test_param_serialization_matrix.lua` around lines 11 - 32,
make_spec mutates the input table param_def by setting param_def.required =
true; instead, create a local copy of param_def inside make_spec (e.g., local
param = {} and shallow-copy fields from param_def, or use a helper shallow-copy)
and set param.required = true when location == "path", then use that local param
in the returned spec (parameters = { param }) so the original param_def remains
unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@t/conformance/test_format_validation.lua`:
- Around line 44-56: The current validate_format function masks ov.compile
failures by returning nil; change it to hard-fail on compile errors (so negative
tests don't treat compile-time failures as passing). In validate_format, after
calling ov.compile(spec) (referenced here as ov.compile and local v, err),
replace the nil return with a raised error or assert that includes the compile
error (tostring(err)) and context (e.g., the format_name and spec) so test
failures show the actual compile problem before calling v:validate_request.
- Line 3: The comment stating "Covers uuid, date, date-time, uri, email, ipv4,
ipv6, hostname formats." is inaccurate because ipv6 isn't tested; either add
explicit ipv6 test cases to the test suite (mirror how ipv4/hostname/email tests
are written) or remove "ipv6" from that comment so it reflects the actual
coverage; update the comment string accordingly in the test header that
currently lists the formats to keep documentation and tests in sync.

---

Nitpick comments:
In `@t/conformance/test_param_serialization_matrix.lua`:
- Around line 11-32: make_spec mutates the input table param_def by setting
param_def.required = true; instead, create a local copy of param_def inside
make_spec (e.g., local param = {} and shallow-copy fields from param_def, or use
a helper shallow-copy) and set param.required = true when location == "path",
then use that local param in the returned spec (parameters = { param }) so the
original param_def remains unchanged.
🪄 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: CHILL

Plan: Pro

Run ID: 2fe52df0-590e-4b9c-8852-ab2a8a7947bf

📥 Commits

Reviewing files that changed from the base of the PR and between 1452e0e and 7bb90f7.

📒 Files selected for processing (2)
  • t/conformance/test_format_validation.lua
  • t/conformance/test_param_serialization_matrix.lua

Comment thread t/conformance/test_format_validation.lua Outdated
Comment thread t/conformance/test_format_validation.lua
Comment thread .github/workflows/test.yml Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/test.yml:
- Around line 41-42: The JSONSCHEMA_PATH selection uses a non-deterministic find
+ head which can pick an arbitrary match; change the script around the
JSONSCHEMA_PATH assignment so it either restricts the find to the exact expected
path (e.g., constrain to the Lua 5.1 share/lua path) or collects matches and
fails if the number of results is not exactly one, and only then assigns
JSONSCHEMA_PATH and performs the sudo cp; update the logic that references
JSONSCHEMA_PATH to exit with an error if multiple or zero matches are found to
make the overlay deterministic.
🪄 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: CHILL

Plan: Pro

Run ID: 4b41c787-de92-4d41-8435-849e50c1c7cd

📥 Commits

Reviewing files that changed from the base of the PR and between 7bb90f7 and 989c4e0.

📒 Files selected for processing (1)
  • .github/workflows/test.yml

Comment thread .github/workflows/test.yml Outdated
Comment thread .github/workflows/test.yml Outdated
Comment thread .github/workflows/test.yml Outdated
@nic-6443 nic-6443 merged commit 3aaae5b into main Apr 21, 2026
3 checks passed
@nic-6443 nic-6443 deleted the feat/p1-fixes branch April 21, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants