Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces comprehensive unit test coverage for all custom UKHSA Spectral rules to enable automated validation in the CI/CD pipeline. The tests verify correct error generation, rule severity levels, and message outputs for each rule.
- Adds positive and negative test cases for each custom UKHSA rule
- Ensures rules behave correctly across Spectral version changes
- Provides regression protection for future rule modifications
Reviewed Changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/rules/should-support-application-json-content-request-body.test.ts | Tests validation that request bodies should support application/json content type |
| src/tests/rules/should-not-use-api-as-base-path.test.ts | Tests disabled rule for /api base path validation |
| src/tests/rules/should-have-location-header-in-201-response.test.ts | Tests validation that 201 responses should include Location header |
| src/tests/rules/should-define-api-root.test.ts | Tests validation that APIs should define a root path (/) |
| src/tests/rules/oas3-api-servers.test.ts | Tests disabled OAS3 servers rule |
| src/tests/rules/must-use-valid-version-info-schema.test.ts | Tests validation of version info schema at API root endpoint |
| src/tests/rules/must-use-snake-case-for-query-parameters.test.ts | Tests disabled snake_case query parameter rule |
| src/tests/rules/must-use-snake-case-for-property-names.test.ts | Tests disabled snake_case property naming rule |
| src/tests/rules/must-use-normalized-paths.test.ts | Tests validation that paths start with slash and avoid trailing slashes |
| src/tests/rules/must-use-normalized-paths-without-trailing-slash.test.ts | Tests disabled trailing slash validation rule |
| src/tests/rules/must-use-https-protocol-only.test.ts | Tests validation that server URLs must use HTTPS protocol |
| src/tests/rules/must-use-camel-case-for-query-parameters.test.ts | Tests validation that query parameters use camelCase naming |
| src/tests/rules/must-use-camel-case-for-property-names.test.ts | Tests validation that properties use camelCase naming |
| src/tests/rules/must-return-200-for-api-root.test.ts | Tests validation that root path defines 200 response |
| src/tests/rules/must-provide-api-audience.test.ts | Tests disabled legacy API audience rule |
| src/tests/rules/must-not-use-http-basic-authentication.test.ts | Tests validation that HTTP Basic authentication is prohibited |
| src/tests/rules/must-not-define-request-body-for-get-requests.test.ts | Tests validation that GET requests cannot have request bodies |
| src/tests/rules/must-have-info-x-api-id.test.ts | Tests disabled info.x-api-id validation rule |
| src/tests/rules/must-have-info-value-chain.test.ts | Tests validation of required x-value-chain field with enumerated values |
| src/tests/rules/must-have-info-api-audience.test.ts | Tests validation of required x-audience field with enumerated values |
| src/tests/rules/must-define-security-schemes.test.ts | Tests validation that APIs must define security schemes |
| src/tests/rules/must-define-security-problem-responses.test.ts | Tests validation that secured operations define 401/403 Problem Details responses |
| src/tests/rules/must-define-critical-problem-responses.test.ts | Tests validation that operations define 400/404/500 Problem Details responses |
| src/tests/rules/must-always-return-json-objects-as-top-level-data-structures.test.ts | Tests validation that JSON responses use object as top-level type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16
Summary
This PR introduces a unit-testing setup for all custom Spectral rules to ensure rule quality, prevent regressions, and allow automated validation within the CI/CD pipeline used to build the Spectral npm package.
Changes Made
Test Coverage for Existing Rules