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

Remove drf yasg #24

Merged
merged 21 commits into from
Dec 11, 2024
Merged

Remove drf yasg #24

merged 21 commits into from
Dec 11, 2024

Conversation

CharString
Copy link

@CharString CharString commented Feb 13, 2024

Passes test, but please try use it and add test cases where your project breaks.

Fixes #29

@codecov-commenter
Copy link

codecov-commenter commented Feb 13, 2024

Codecov Report

Attention: Patch coverage is 65.82633% with 122 lines in your changes missing coverage. Please review.

Project coverage is 57.79%. Comparing base (9563533) to head (56c2190).
Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
vng_api_common/permissions.py 23.65% 71 Missing ⚠️
vng_api_common/schema.py 73.07% 25 Missing and 10 partials ⚠️
vng_api_common/extensions/field_extensions.py 83.05% 8 Missing and 2 partials ⚠️
vng_api_common/extensions/serializer_extensions.py 87.87% 2 Missing and 2 partials ⚠️
vng_api_common/generators.py 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
+ Coverage   54.95%   57.79%   +2.83%     
==========================================
  Files          79       73       -6     
  Lines        3632     3239     -393     
  Branches      590      431     -159     
==========================================
- Hits         1996     1872     -124     
+ Misses       1533     1275     -258     
+ Partials      103       92      -11     

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

@annashamray annashamray self-requested a review February 13, 2024 11:48
@annashamray
Copy link

Please don't merge this PR before I review it

Copy link

@annashamray annashamray 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 there are some drf-yasg leftovers:

  1. all files in bin folder are using drf-yasg now. I think patch_content_types and use_external_components can be removed. So are the related management commands
  2. All files in inspectors folder still have drf-yasg imports and code. This should be replaces with drf_spectacular extensions
  3. drf-yasg and drf-spectacular have different generation for operation_ids, for the backward compatibility could you keep the same operation_ids as before?

vng_api_common/schema.py Outdated Show resolved Hide resolved
testapp/schema.py Outdated Show resolved Hide resolved
testapp/viewsets.py Outdated Show resolved Hide resolved
vng_api_common/conf/api.py Outdated Show resolved Hide resolved
vng_api_common/conf/api.py Outdated Show resolved Hide resolved
vng_api_common/generators.py Outdated Show resolved Hide resolved
vng_api_common/generators.py Outdated Show resolved Hide resolved

def create_view(self, callback, method, request=None):
if (
method != "HEAD"

Choose a reason for hiding this comment

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

What happens if method == HEAD ?

Choose a reason for hiding this comment

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

This question remains.

Choose a reason for hiding this comment

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

Changed

vng_api_common/notifications/api/views.py Show resolved Hide resolved
vng_api_common/schema.py Show resolved Hide resolved
Copy link

@Coperh Coperh 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 its fine ¯\_(ツ)_/¯

Copy link

@SonnyBA SonnyBA left a comment

Choose a reason for hiding this comment

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

Whenever Open-Zaak upgrades to this version, I think it can remove some code and reuse code that was added here.

I do think it would be nice to add back the tests for the etag header code and the custom content-type stuff.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Show resolved Hide resolved
.github/workflows/code_quality.yml Show resolved Hide resolved
bin/generate_schema Show resolved Hide resolved
tests/test_cache_headers.py Show resolved Hide resolved
vng_api_common/extensions/field_extensions.py Outdated Show resolved Hide resolved
vng_api_common/oas.py Show resolved Hide resolved
vng_api_common/permissions.py Outdated Show resolved Hide resolved
AUDIT_TRAIL_ENABLED = apps.is_installed("vng_api_common.audittrails")


def _view_supports_audittrail(view: viewsets.ViewSet) -> bool:
Copy link

Choose a reason for hiding this comment

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

The comment in the permissions files applies here too I guess

Copy link

@annashamray annashamray Nov 20, 2024

Choose a reason for hiding this comment

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

This function is just moved from inspectors folder. I moved it to vng_api_common.audittrails.utils file
But I agree with you, we can reuse some schema customization from here in Open Zaak, I'll create an issue for it

setup.cfg Outdated Show resolved Hide resolved
vng_api_common/conf/api.py Outdated Show resolved Hide resolved
vng_api_common/conf/api.py Show resolved Hide resolved
vng_api_common/conf/api.py Outdated Show resolved Hide resolved
vng_api_common/extensions/field_extensions.py Outdated Show resolved Hide resolved
vng_api_common/extensions/field_extensions.py Outdated Show resolved Hide resolved
vng_api_common/extensions/serializer_extensions.py Outdated Show resolved Hide resolved
),
]

def get_override_parameters(self):

Choose a reason for hiding this comment

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

This method is declared twice

Choose a reason for hiding this comment

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

fixed

vng_api_common/notifications/api/views.py Outdated Show resolved Hide resolved
vng_api_common/permissions.py Outdated Show resolved Hide resolved
tests/test_schema.py Show resolved Hide resolved
@annashamray annashamray force-pushed the drf-spectacular branch 2 times, most recently from c3bba7a to 59e682e Compare November 26, 2024 15:51
vng_api_common/conf/api.py Outdated Show resolved Hide resolved
vng_api_common/extensions/field_extensions.py Outdated Show resolved Hide resolved
vng_api_common/extensions/field_extensions.py Outdated Show resolved Hide resolved
vng_api_common/extensions/serializer_extensions.py Outdated Show resolved Hide resolved
setup.cfg Outdated
install_requires =
django>=3.2.0
django-filter>=2.0
django-solo
djangorestframework>=3.11.0
djangorestframework_camel_case>=1.2.0
django-rest-framework-condition
drf-yasg>=1.20.0
drf-extra-fields>=3.7.0

Choose a reason for hiding this comment

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

moved it to optional dependencies


def create_view(self, callback, method, request=None):
if (
method != "HEAD"

Choose a reason for hiding this comment

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

Changed

Comment on lines 32 to 36
and hasattr(callback.cls, "_conditional_retrieves")
and "head" not in callback.actions
):
# hack to get test_schema_root_tags pass when run in isolation
callback.actions["head"] = callback.cls._conditional_retrieves[0]

Choose a reason for hiding this comment

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

changed

vng_api_common/notifications/api/views.py Outdated Show resolved Hide resolved
tests/test_content_type_headers.py Outdated Show resolved Hide resolved
),
]

def get_override_parameters(self):

Choose a reason for hiding this comment

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

fixed

@annashamray annashamray dismissed their stale review November 28, 2024 14:59

All changes are implemented

@annashamray
Copy link

@SonnyBA Could you please review it? I can't merge it because you request changes

CHANGELOG.rst Show resolved Hide resolved
if method == "HEAD":
return {}
return super().get_overrides(view, method)
# todo support registering and reusing Response components
Copy link

Choose a reason for hiding this comment

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

Is this meant to be picked up by a separate ticket?

Choose a reason for hiding this comment

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

I've created an issue for it - #55

vng_api_common/schema.py Outdated Show resolved Hide resolved
@annashamray annashamray merged commit 684b6b9 into main Dec 11, 2024
6 checks passed
@annashamray annashamray deleted the drf-spectacular branch December 11, 2024 10:22
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.

Replace drf-yasg with drf-spectacular
6 participants