Skip to content

Fix swagger API docs generation - #1366

Merged
TG1999 merged 6 commits into
mainfrom
fix-api-bulk-search-doc
Dec 15, 2023
Merged

Fix swagger API docs generation#1366
TG1999 merged 6 commits into
mainfrom
fix-api-bulk-search-doc

Conversation

@keshav-space

Copy link
Copy Markdown
Member

- Use `extend_schema` to override the request body, which was not being properly discovered.

- drf-spectacular relies on `get_serializer_class()` and `get_serializer()`, and it works well for view functions that purely deal with ModelSerializer. For anything else, it gets a bit murky, and it is advised to provide proper overrides in the `extend_schema` decorator.

- Override erroneous pagination and filter backend caused due to response containing multiple serializer object https://drf-spectacular.readthedocs.io/en/latest/faq.html#my-action-is-erroneously-paginated-or-has-filter-parameters-that-i-do-not-want

Signed-off-by: Keshav Priyadarshi <git@keshav.space>
@keshav-space
keshav-space requested a review from TG1999 December 13, 2023 18:05
@keshav-space keshav-space added bug API documentation Everything about documentation labels Dec 13, 2023
Comment thread vulnerabilities/api.py
Comment thread vulnerabilities/tests/test_api.py
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
@keshav-space
keshav-space requested a review from TG1999 December 14, 2023 16:51

@TG1999 TG1999 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@TG1999 TG1999 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@keshav-space thanks! can you also check for lookup and bulk_lookup endpoint as well

Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
@keshav-space keshav-space changed the title Fix swagger API doc for api/packages/bulk_search/ Fix swagger API docs generation Dec 14, 2023
@keshav-space
keshav-space requested a review from TG1999 December 15, 2023 07:47

@TG1999 TG1999 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@TG1999
TG1999 merged commit e9c280d into main Dec 15, 2023
@keshav-space
keshav-space deleted the fix-api-bulk-search-doc branch December 15, 2023 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API bug documentation Everything about documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants