-
-
Notifications
You must be signed in to change notification settings - Fork 777
Fix clone() method using processed spec instead of raw specFix spec.py #2080
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
base: main
Are you sure you want to change the base?
Conversation
See issue spec-first#2078
Why Validating Processed Specs is Conceptually WrongTechnical Analysis by Claude AI The Core IssueThe What happens during
|
I think this might almost be a duplicate of PR #1889? That PR has been ignored by the maintainers for a long time. Now you have come along and done heroic work in figuring it out all over again! Until this fix or something like it gets merged, V3 remains fundamentally broken. I just don't know how to raise the priority of this in the queue. |
Thank you @chrisinmtown, let me see if I can propose a slight modification to account for external refs |
Fix clone() to use appropriate spec based on ref types Use _raw_spec for internal refs only, _spec for external refs. Prevents validation failures from resolved schema artifacts while maintaining compatibility with relative refs tests. Fixes spec-first#2078
for more information, see https://pre-commit.ci
New commit pushed with conditional cloning approachI've updated the implementation to address the concerns about external references from PR #1889. The new approach:
This should maintain compatibility with the existing The @RobbeSneyders This approach should address your previous concerns about test failures while still solving the core validation inconsistency issue. |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
To be honest, I see all 802 tests passing (in my local WSL) even with my original one-line fix, but I added the conditional handler to be on the safe side. Testing ResultsDuring testing, I verified that the The conditional handler was added for safety to handle potential external reference cases not covered by the current test suite. Key Findings:
|
- Adds test_clone_external_refs.py to validate clone() behavior - Ensures both internal and external reference scenarios are covered - Increases test coverage from 802 to 803 tests
Problem
When Swagger UI accesses
/docs/
endpoint, it callswith_base_path()
which triggersclone()
. The current implementation usescopy.deepcopy(self._spec)
(processed spec) instead of the original raw specification, causing validation failures that don't occur during app startup.Root Cause
The
clone()
method at line 207 creates a new instance fromself._spec
(already processed and resolved) rather thanself._raw_spec
(original). Thedeepcopy
operation can corrupt internal references and circular dependencies in the processed spec.Fix
Fixes #2078