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

fix(api): Actually order body params by required vs optional #57244

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/sentry/apidocs/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from collections import OrderedDict
from typing import Any, Dict, List, Literal, Mapping, Set, Tuple, TypedDict

from jsonref import JsonRef

from sentry.api.api_owners import ApiOwner
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.apidocs.api_ownership_allowlist_dont_modify import API_OWNERSHIP_ALLOWLIST_DONT_MODIFY
Expand Down Expand Up @@ -195,6 +197,10 @@ def custom_preprocessing_hook(endpoints: Any) -> Any: # TODO: organize method,


def custom_postprocessing_hook(result: Any, generator: Any, **kwargs: Any) -> Any:
# Populate references with lazy lookup objects. This is required so we can
# order request body parameters by required and optional.
result = JsonRef.replace_refs(result)

for path, endpoints in result["paths"].items():
for method_info in endpoints.values():
_check_tag(path, method_info)
Expand All @@ -216,7 +222,8 @@ def custom_postprocessing_hook(result: Any, generator: Any, **kwargs: Any) -> An
if "requestBody" in method_info:
try:
content = method_info["requestBody"]["content"]
# media type can either "multipart/form-data" or "application/json"
# Media type can either "multipart/form-data" or "application/json"
# The schema is always populated b/c we fetched all references in the beginning
if "multipart/form-data" in content:
schema = content["multipart/form-data"]["schema"]
else:
Expand Down
Loading