Skip to content

Comments

feat: KEH-171 enhance API documentation with OpenAPI schemas#593

Open
pexxi wants to merge 1 commit intomainfrom
keh-171-add-openapi-spec-generation
Open

feat: KEH-171 enhance API documentation with OpenAPI schemas#593
pexxi wants to merge 1 commit intomainfrom
keh-171-add-openapi-spec-generation

Conversation

@pexxi
Copy link

@pexxi pexxi commented Dec 9, 2025

KEH-171 - Enhance API documentation

  • Added new dependencies drf-spectacular and PyYAML to requirements.in.
  • Enhanced various viewsets in the democracy app with OpenAPI schema annotations for better API documentation.

Note: This will not yield to a perfect result immediately, but it should come close. There are some custom implementations in this projects where spectacular cannot help out-of-the-box. That's where manual work is needed.

Refs: KEH-171

@pexxi pexxi force-pushed the keh-171-add-openapi-spec-generation branch 5 times, most recently from a4d9ff0 to 27d0b7b Compare December 9, 2025 13:33
@terovirtanen
Copy link
Contributor

KERROKANTASI-API branch is deployed to platta: https://kerrokantasi-pr593.api.dev.hel.ninja 🚀🚀🚀

@pexxi pexxi marked this pull request as ready for review December 10, 2025 12:53
@pexxi pexxi requested a review from a team as a code owner December 10, 2025 12:53
@pexxi
Copy link
Author

pexxi commented Dec 10, 2025

KERROKANTASI-API branch is deployed to platta: https://kerrokantasi-pr593.api.dev.hel.ninja 🚀🚀🚀

This should not probably happen if the PR is in draft mode?

@terovirtanen
Copy link
Contributor

KERROKANTASI-API branch is deployed to platta: https://kerrokantasi-pr593.api.dev.hel.ninja 🚀🚀🚀

1 similar comment
@terovirtanen
Copy link
Contributor

KERROKANTASI-API branch is deployed to platta: https://kerrokantasi-pr593.api.dev.hel.ninja 🚀🚀🚀

@pexxi pexxi force-pushed the keh-171-add-openapi-spec-generation branch from e07e68c to bc2826f Compare December 18, 2025 08:38
@terovirtanen
Copy link
Contributor

KERROKANTASI-API branch is deployed to platta: https://kerrokantasi-pr593.api.dev.hel.ninja 🚀🚀🚀

@pexxi pexxi requested a review from nicobav January 9, 2026 10:28
@azure-pipelines
Copy link

KERROKANTASI-API branch is deployed to platta: https://kerrokantasi-pr593.api.dev.hel.ninja 🚀🚀🚀

- Added new dependencies `drf-spectacular` and `PyYAML`.
- Enhanced various viewsets in the democracy app with OpenAPI schema
annotations for better API documentation.

Ref: KEH-171
@pexxi pexxi force-pushed the keh-171-add-openapi-spec-generation branch from 49a2db7 to 96bfc95 Compare January 23, 2026 08:18
@sonarqubecloud
Copy link

@azure-pipelines
Copy link

KERROKANTASI-API branch is deployed to platta: https://kerrokantasi-pr593.api.dev.hel.ninja 🚀🚀🚀

Copy link
Contributor

Choose a reason for hiding this comment

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

I started to ponder is this something we want here in the repository 🤔
To me it mostly looks like a one-timer

@nicobav
Copy link
Contributor

nicobav commented Jan 27, 2026

Looks a OK to me. Let's chat about the prompt and then merge 🚀

Comment on lines +12 to +27
# ============================================================================
# Pagination Parameters
# ============================================================================

PAGINATION_PARAMS = [
OpenApiParameter(
"limit",
OpenApiTypes.INT,
description="Number of results per page",
),
OpenApiParameter(
"offset",
OpenApiTypes.INT,
description="Offset for pagination",
),
]
Copy link
Contributor

Choose a reason for hiding this comment

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

These are not needed, they generated automatically by drf-spectacular.

Comment on lines +42 to +48
ORDERING_PARAM = [
OpenApiParameter(
"ordering",
OpenApiTypes.STR,
description="Sort field (prefix - for descending order)",
),
]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not needed, equivalent ordering documentation is generated automatically by drf-spectacular.

However, the automatically generated ordering documentation doesn't seem to include the fields that can be used for ordering, so more specific descriptions that include the fields, like HEARING_ORDERING_PARAM are still a good idea.

Comment on lines +100 to +234
# ============================================================================
# Root-Level Comment Filter Parameters
# ============================================================================

ROOT_COMMENT_FILTER_PARAMS = [
OpenApiParameter(
"hearing",
OpenApiTypes.STR,
description="Filter by hearing ID",
),
OpenApiParameter(
"section",
OpenApiTypes.STR,
description="Filter by section ID",
),
OpenApiParameter(
"comment",
OpenApiTypes.STR,
description="Filter by parent comment ID",
),
OpenApiParameter(
"label",
OpenApiTypes.STR,
description="Filter by label ID",
),
OpenApiParameter(
"pinned",
OpenApiTypes.BOOL,
description="Filter for pinned comments",
),
OpenApiParameter(
"created_by",
OpenApiTypes.STR,
description="Filter by creator ('me' for current user)",
),
OpenApiParameter(
"created_at__lt",
OpenApiTypes.DATETIME,
description="Filter comments created before this date",
),
OpenApiParameter(
"created_at__gt",
OpenApiTypes.DATETIME,
description="Filter comments created after this date",
),
]

# ============================================================================
# Hearing Filter Parameters
# ============================================================================

HEARING_FILTER_PARAMS = [
OpenApiParameter(
"title",
OpenApiTypes.STR,
description="Filter by title (case-insensitive contains)",
),
OpenApiParameter(
"open_at_lte",
OpenApiTypes.DATETIME,
description="Filter hearings opening at or before this date",
),
OpenApiParameter(
"open_at_gt",
OpenApiTypes.DATETIME,
description="Filter hearings opening after this date",
),
OpenApiParameter(
"label",
OpenApiTypes.STR,
description="Filter by label ID (comma-separated for multiple)",
),
OpenApiParameter(
"published",
OpenApiTypes.BOOL,
description="Filter by published status",
),
OpenApiParameter(
"open",
OpenApiTypes.BOOL,
description="Filter by open/closed status",
),
OpenApiParameter(
"following",
OpenApiTypes.BOOL,
description="Filter hearings followed by current user",
),
OpenApiParameter(
"created_by",
OpenApiTypes.STR,
description="Filter by creator ('me' for current user or organization name)",
),
]

# ============================================================================
# Section Filter Parameters
# ============================================================================

SECTION_FILTER_PARAMS = [
OpenApiParameter(
"hearing",
OpenApiTypes.STR,
description="Filter by hearing ID",
),
OpenApiParameter(
"type",
OpenApiTypes.STR,
description="Filter by section type identifier",
),
]

SECTION_IMAGE_FILTER_PARAMS = [
OpenApiParameter(
"hearing",
OpenApiTypes.STR,
description="Filter by hearing ID",
),
OpenApiParameter(
"section",
OpenApiTypes.STR,
description="Filter by section ID",
),
]

# ============================================================================
# Label Filter Parameters
# ============================================================================

LABEL_FILTER_PARAMS = [
OpenApiParameter(
"label",
OpenApiTypes.STR,
description="Filter by label text (case-insensitive contains)",
),
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Any of these shouldn't be needed, the same descriptions are included as help_texts.

- Session Authentication for browsable API
- Anonymous read access for public content
""",
"VERSION": "1.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this be somehow automatically updated? If not, IMO it would better to set it as None because most probably it won't be updated at all in the future 🙂

Comment on lines +166 to +172
# Pagination
PAGINATION_PARAMS = [
OpenApiParameter("limit", OpenApiTypes.INT,
description="Results per page"),
OpenApiParameter("offset", OpenApiTypes.INT,
description="Offset for pagination"),
]
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this should be in the prompt because it shouldn't be ever needed (because drf-spectacular generates it automatically).

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.

5 participants