jmlue42 / spectral-jsonapi-ruleset

A Stoplight/Spectral linting ruleset for the JSON:API specification.
MIT License
12 stars 8 forks source link

Changes updated for API-54-Error-Processing-Errors #57

Closed saujany closed 9 months ago

saujany commented 9 months ago

API-54 Error.ProcessingErrors (#57)

This commit updates the resovleRef function ti maintain the integrity of the original OpenAPI document. Previously, the function removed resolved components from the document's components section, which led to issues in subsequent reuse of the document, especially in test environments where the same document was dereferenced multiple times.

The refacotring includes: = Removing the logic that deletes components from the root document after resolution.

This change ensures that eash test or operation that involves dereferencing an OpenAPI document works with a complete and unaltered version of the document, thereby preventing errors related to missing components in later tests or operations. It enhances the reliability and repeatability of tests and operations that depend on the OpenAPI document.

This commit introduces a new set of Spectral rules specifically tailored for validating JSON:API v1.0 Resource Objects Attributes within an OpenAPI Document. Key highlights include:

These additions significantly improve our capability to automatically validate and ensure the consistency of API responses with the JSON:API v1.0 standard.

This document serves as a standardized template for verifying positive test scenarios in ruleset development. To ensure that the document can be tested against multiple rulesets, the design and endpoints were refactored. This document is now closer to adhering to JSON:API v1.0 specifications. Covered sections include:

This commit marks the completion of detailed test cases for all of the JSON:API v1.0 Document Structure Resource Objects Attributes ruleset:

These updates significantly improve the robustness and relaibility of the JSON:API v1.0 specifications for Resource Objects Attributes validation process.

Extended the default timeout setting for Mocha tests to 10000 milliseconds. This change addresses issues with asynchronous test exceeding the previous 2000ms default timeout, ensuring more reliable test executions, particularly in environments with variable response times or for tests requiring extended execution time.

Key Changes and Reasons:

  1. Performance Optimization:

    • As our API template grows, the number of test cases that require a dereferenced version of validApiDocument is increasing.
    • Previously, each test file was individually dereferencing this document, which is a resource-intensive process. By dereferencing it once globally, we reduce the computational overhead significantly.
    • This global approach ensures that all tests use the same dereferenced instance, improving the overall efficiency of our test execution.
  2. Resolving Multiple Dereferencing Issues:

    • In our prior setup, attempting to dereference an already dereferenced document in different test files led to inconsistencies and potential errors.
    • By having a single, globally dereferenced document, we eliminate the risk of such issues. This ensures that all tests work with a consistent and stable version of the API document.
  3. Maintainability and Consistency:

    • This refactor simplifies the test setup by removing redundant dereferencing logic in multiple files.
    • It also enhances the consistency across our test suites, making it easier for the team to write and maintain tests.

By making this change, we are aligning our testing practices with best practices for efficiency, stability, and maintainability. This update is crucial for handling the increasing complexity of our API testing as the project grows.