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

Improved Django skel template #447

Merged
merged 2 commits into from
Aug 6, 2024
Merged

Conversation

victorskl
Copy link
Member

  • Replaced drf_yasg with drf_spectacular
  • Removed version pinning as skel template

* Replaced drf_yasg with drf_spectacular
* Removed version pinning as skel template
@victorskl victorskl self-assigned this Aug 5, 2024
@victorskl victorskl added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file labels Aug 5, 2024
@victorskl
Copy link
Member Author

victorskl commented Aug 5, 2024

This shall tame few recurring alerts related to skel in https://github.com/umccr/orcabus/security/dependabot for good.

@williamputraintan
Copy link
Member

I think you will also need to add the pagination schema in the pagination.py that match to the get_paginated_response function.

    def get_paginated_response_schema(self, schema):
        return {
            "type": "object",
            'required': ['links', 'pagination', 'results'],
            "properties": {
                "links": {
                    "type": "object",
                    "properties": {
                        "next": {"type": "string", "format": "uri", "nullable": True,
                                 'example': 'http://api.example.org/accounts/?{page_query_param}=4'.format(
                                     page_query_param=self.page_query_param)},
                        "previous": {"type": "string", "format": "uri", "nullable": True,
                                     'example': 'http://api.example.org/accounts/?{page_query_param}=2'.format(
                                         page_query_param=self.page_query_param)},
                    },
                },
                "pagination": {
                    "type": "object",
                    "properties": {
                        PaginationConstant.COUNT: {"type": "integer"},
                        PaginationConstant.PAGE: {"type": "integer"},
                        PaginationConstant.ROWS_PER_PAGE: {"type": "integer"},
                    },
                },
                "results": schema
            },
        }

Ref: https://stackoverflow.com/questions/71431687/how-to-generate-a-schema-for-a-custom-pagination-in-django-rfw-with-drf-spectacu

@victorskl
Copy link
Member Author

Fixed pagination for schema with d2a05ee

@victorskl victorskl merged commit 093cf10 into main Aug 6, 2024
5 checks passed
@victorskl victorskl deleted the improve-skel-django-20240805 branch August 6, 2024 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants