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

Use the referencing package for resolving schema references #560

Closed
wants to merge 1 commit into from
Closed

Conversation

foarsitter
Copy link
Contributor

For what I found is that the jsonschema validators are compatible with the referencing package resolvers.

This change is at least covered by test_api_payload_strict_verification.

Fixes #553

Copy link
Contributor

@hbusul hbusul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk if reviews from a third party gets a pass but anyway changes looks good to me,
I've run our tests using this branch and nothing failed. But this has no changelog, the contributing guideline states that it should contain one

@peter-doggart could you start the workflows?

@peter-doggart
Copy link
Contributor

Sure thing. Will have a review of this later this evening. :)

@foarsitter
Copy link
Contributor Author

Yesterday everything seemed fine: https://github.com/foarsitter/flask-restx/actions/runs/6237094186/job/16929870907

Today I messed up the branch while on the phone. @hbusul can you see what's the difference?

@peter-doggart
Copy link
Contributor

I think we might run into problems because currently flask-restx supports python 3.7 but the new referencing package does not, just looking at the pipelines that ran previously. Can't check right now, but if python 3.7 is end of life we might need to drop support to make this change.

@foarsitter
Copy link
Contributor Author

Python 3.7 is indeed EOL since 2023-06-27.

@hbusul
Copy link
Contributor

hbusul commented Sep 19, 2023

It is not only referencing but also jsonschema that does not support python 3.7 . With 3.7 it does not even import referencing due to a syntax error. I have nothing against for dropping python 3.7 but I do not know if it should be done with this ticket or it should be announced. What do you think about moving to import statement in try-except and fallback to not supported way but that also gives you time until jsonschema really drops it, maybe to counter that we can fix the version and when we get rid of 3.7 we can unfix the version.

Copy link
Contributor

@peter-doggart peter-doggart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is all fine, since I've merged the drop 3.7 PR. However, can you have a look and resolve the remaining conflict (it's on the changelog) and pull in those changes. I can't fix it because this PR is to merge foarsitter:master.

@foarsitter
Copy link
Contributor Author

Some tests are failing and I'm unable to find a solution.

FAILED tests/test_payload.py::PayloadTest::test_validation_with_inheritance
FAILED tests/test_payload.py::PayloadTest::test_validation_on_list

@hbusul
Copy link
Contributor

hbusul commented Sep 25, 2023

I'm a bit busy but I will try to look at why those are failing ASAP within this week

@codecov
Copy link

codecov bot commented Oct 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3ea4ce1) 96.45% compared to head (2715d4a) 96.44%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #560      +/-   ##
==========================================
- Coverage   96.45%   96.44%   -0.01%     
==========================================
  Files          20       20              
  Lines        2733     2728       -5     
==========================================
- Hits         2636     2631       -5     
  Misses         97       97              
Files Coverage Δ
flask_restx/api.py 96.50% <ø> (-0.06%) ⬇️
flask_restx/model.py 96.96% <100.00%> (+0.04%) ⬆️
flask_restx/resource.py 96.07% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@foarsitter
Copy link
Contributor Author

foarsitter commented Oct 8, 2023

Did some investigation on the issue today. Seems that we do not need referencing after all. #definitions/Person is a local pointer to within the document. Adding resources to the references registry will not help since that adds global reference (i.e. https://yourapi.com/Person).

Instead of keeping a global registry, I added the definitions to the schema that is going to be validated on the fly. In this way the $ref's can be resolved and we do not need an external resolver.

Note: In order to make the tests succeed I needed to pin flask < 3.0.0. If we will accept this solution that commit has to be removed.

@foarsitter foarsitter closed this by deleting the head repository Jan 15, 2024
@dsrink
Copy link

dsrink commented Feb 1, 2024

The last few messages on this PR look strange to me. It seems that this PR was not merged. Could somebody handle this? This issue is bugging me in some of my installations.

@foarsitter
Copy link
Contributor Author

@dsrink sorry, I deleted the fork. Opened #592 to fix this.

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.

jsonschema.RefResolver is deprecated
4 participants