Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for 881 - multiple specs w/validateRequests fail #903

Merged
merged 3 commits into from Feb 10, 2024

Conversation

mzbik
Copy link
Contributor

@mzbik mzbik commented Feb 8, 2024

Problem: Multiple api installations cause installation of chained mung'd json implementations each is bound to a specific apiSpec in the surrounding ResponseValidator. requests are labelled with a specific apiSpec. One (or more) of the chained implementations will then ResponseValidator.validate against a mismatched ResponseValidator.

Solution is:

  1. OpenApiSpecLoader.load() decorates its returned Spec with a unique serial number
  2. OpenApiContext caches this serial number
  3. applyOpenMetadata stores this serial number in the OpenApiRequestMetadata in req.openapi
  4. ResponseValidator.constructor caches the serial number when it is created

And, to make it all work,

  1. ResponseValidator.validate inside the mung'd json, checks to see if the serial number in req.openapi.serial matches the serial number in the containing ResponseValidator instance.

Uses serial number to detect if a response validation occurs in the correct ResponseValidator context

Tests pass
Extracts serial from context (follows convention of code)

Fixes typos

Tests pass
@cdimascio cdimascio merged commit 766806b into cdimascio:master Feb 10, 2024
5 checks passed
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.

None yet

2 participants