Skip to content

test: add comprehensive schema validation unit tests - #125

Merged
SVilgelm merged 3 commits into
mainfrom
test/add-schema-validation-unit-tests
Sep 6, 2025
Merged

SVilgelm merged 3 commits into
mainfrom
test/add-schema-validation-unit-tests

Conversation

@SVilgelm

@SVilgelm SVilgelm commented Sep 6, 2025

Copy link
Copy Markdown
Member

Add a suite of new unit tests for OpenAPI schema validation covering
const/default interactions, enum uniqueness and conflicts, numeric
constraints, exclusive bounds, fraction multipleOf behavior, and schema
"dollarSchema" URI validation.

Key additions:

  • TestSchemaConstWithMatchingDefaultInteger and
    TestSchemaConstWithNonMatchingDefaultError to validate const vs default
    value handling.
  • TestSchemaEnumDuplicateValueError and TestSchemaConstWithEnumConflict to
    ensure enums reject duplicate values and incompatible const+enum usage.
  • TestSchemaFractionalMultipleOfAllowed to allow fractional multipleOf
    (e.g., 0.01) with numeric ranges.
  • TestSchemaInvalidMaximumLessThanMinimumError and
    TestSchemaExclusiveMaximumLessThanExclusiveMinimumError to enforce min/max
    ordering for inclusive and exclusive bounds.
  • TestSchemaDollarSchemaAbsoluteURIOk and
    TestSchemaDollarSchemaNonAbsoluteURIError to require dollarSchema be an
    absolute URI.
  • Begin adding TestSchema_MaxContainsWithoutContains_Error (incomplete in
    diff) to cover contains/maxContains relationships.

These tests increase coverage of schema validation rules and prevent
regressions by asserting both valid schemas pass and invalid schemas
produce descriptive errors.

Add a suite of new unit tests for OpenAPI schema validation covering
const/default interactions, enum uniqueness and conflicts, numeric
constraints, exclusive bounds, fraction multipleOf behavior, and schema
"dollarSchema" URI validation.

Key additions:
- TestSchemaConstWithMatchingDefaultInteger and
  TestSchemaConstWithNonMatchingDefaultError to validate const vs default
  value handling.
- TestSchemaEnumDuplicateValueError and TestSchemaConstWithEnumConflict to
  ensure enums reject duplicate values and incompatible const+enum usage.
- TestSchemaFractionalMultipleOfAllowed to allow fractional multipleOf
  (e.g., 0.01) with numeric ranges.
- TestSchemaInvalidMaximumLessThanMinimumError and
  TestSchemaExclusiveMaximumLessThanExclusiveMinimumError to enforce min/max
  ordering for inclusive and exclusive bounds.
- TestSchemaDollarSchemaAbsoluteURIOk and
  TestSchemaDollarSchemaNonAbsoluteURIError to require dollarSchema be an
  absolute URI.
- Begin adding TestSchema_MaxContainsWithoutContains_Error (incomplete in
  diff) to cover contains/maxContains relationships.

These tests increase coverage of schema validation rules and prevent
regressions by asserting both valid schemas pass and invalid schemas
produce descriptive errors.
Copilot AI review requested due to automatic review settings September 6, 2025 04:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive unit tests for OpenAPI schema validation to ensure proper handling of schema constraints and prevent regressions. The tests cover validation rules for const/default value interactions, enum constraints, numeric bounds, and URI validation.

Key changes:

  • Tests for const/default value validation and enum uniqueness/conflicts
  • Validation of numeric constraints including min/max bounds and fractional multipleOf
  • URI validation for the dollarSchema field and contains/maxContains relationships

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
schema_test.go Adds 11 new unit tests covering schema validation scenarios for const/default, enum, numeric constraints, and URI validation
schema.go Updates schema validation logic to support new test cases, including type changes from int to float64 for numeric fields and enhanced validation rules

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread schema.go Resolved
Comment thread schema.go Resolved
SVilgelm and others added 2 commits September 5, 2025 21:54
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SVilgelm
SVilgelm merged commit 7a916af into main Sep 6, 2025
@SVilgelm
SVilgelm deleted the test/add-schema-validation-unit-tests branch September 6, 2025 04:58
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

⌂ 换网址