-
-
Notifications
You must be signed in to change notification settings - Fork 778
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
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
Good job @giuliohome. Why isn't this PR merged? |
@Ruwann @RobbeSneyders Ping! Would you mind merging this? |
I am critically dependent on this package and have the same question. FWIW I have personally never encountered a situation like this in the open-source world, with a popular (as far as I can tell) package and an active community, but disengaged maintainers. It's deeply concerning. |
Thanks @giuliohome I don't think the conditional handler is the way to go though. I assume the original issue addressed by #2002 was that the cloned spec was initialized without access to the I believe the following should work:
Could you try this and validate if your added test still passes? |
hi @giuliohome I hope you don't mind me trying to follow the new suggestion and gather evidence about your PR. I made the change shown below, then ran tests. With this change in place, in my local the py3.9 .. py3.12 tests all pass including your new test case for external references. I think that's good news. What about the py3.8 tests? When I try
|
Thanks for getting back to this. I’ve since moved on to another solution, so please feel free to continue on your end or close this PR. |
@giuliohome please say, do you have a better solution to share with the community here? |
Ah, I just meant we moved to another library for our use case. The proposed code should still work fine for this specific PR, but more broadly we needed something with a bit more active maintenance. |
Is there a direct competitor to connexion? Please share the name, I have similar concerns about the lack of active maintenance. |
Closing, replaced by #2089 |
This PR fixes an issue introduced in #2002, and the original issue #2002 was trying to address. The original issue was that a cloned spec did not have properly resolved references. #2002 fixed this incorrectly by cloning the resolved spec, while the `Spec` initializer expects a raw spec. This PR fixes this by cloning the raw spec, and passing the `base_uri` required to resolve it along to the initializer of the new `Spec` instance. The swagger ui was also updated to use the resolved spec instead of the raw spec. Supersedes: #1889 #2080 Fixes: #1890 #1909 #2028 #2029
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