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

fix(server): Update context find logic in context-registry #943

Merged
merged 3 commits into from
Jun 13, 2024

Conversation

dethell
Copy link
Collaborator

@dethell dethell commented Jun 7, 2024

If an OpenApi spec has multiple paths that share the same root, but different child paths, if those parent paths are a mixture of cases, the context registry stores the contexts for the paths once (which is correct), but the .find operation in context-registry expects the map key to match the path.

For example, suppose a spec has paths of myPets/vaccinations as well as mypets/visits. Now suppose the user has created a _.context.ts file at routes/myPets/_.context.ts. When a request comes in for myPets/vaccinations it will find the custom context, but when the request comes in for mypets/visits it will fail to find the custom context because it will look for a parent path of mypets and nothing exists in the ContextRegistry.entries for that key.

This PR fixes the path find logic.

Copy link

changeset-bot bot commented Jun 7, 2024

🦋 Changeset detected

Latest commit: 2ff9fdf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
counterfact Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dethell dethell requested a review from pmcelhaney June 7, 2024 16:13
@pmcelhaney
Copy link
Owner

Great find and fix! Can you add a unit test?

@dethell
Copy link
Collaborator Author

dethell commented Jun 13, 2024

Great find and fix! Can you add a unit test?

Done.

@coveralls
Copy link
Collaborator

coveralls commented Jun 13, 2024

Pull Request Test Coverage Report for Build 9502407377

Details

  • 14 of 14 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.06%) to 87.296%

Totals Coverage Status
Change from base Build 9499191401: 0.06%
Covered Lines: 3241
Relevant Lines: 3747

💛 - Coveralls

@pmcelhaney pmcelhaney merged commit e5602fb into main Jun 13, 2024
8 checks passed
@pmcelhaney pmcelhaney deleted the server-context-registry-find-fix branch June 13, 2024 22:01
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.

3 participants