Skip to content

Commit

Permalink
feat(docs) Add server metadata to files endpoints (#82159)
Browse files Browse the repository at this point in the history
Several of our files endpoints require usage of the region domains
instead of sentry.io or slug.sentry.io. Having the server context
defined in these endpoints will enable us to generate better example
code in the docs.

Refs #81232
  • Loading branch information
markstory authored and evanh committed Dec 17, 2024
1 parent 3e75415 commit 88fd57c
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 8 deletions.
12 changes: 8 additions & 4 deletions api-docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
},
"servers": [
{
"url": "https://us.sentry.io/"
},
{
"url": "https://de.sentry.io/"
"url": "https://{region}.sentry.io",
"variables": {
"region": {
"default": "us",
"description": "The data-storage-location for an organization",
"enum": ["us", "de"]
}
}
}
],
"tags": [
Expand Down
3 changes: 3 additions & 0 deletions api-docs/paths/projects/dsyms.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
{
"auth_token": ["project:write"]
}
],
"servers": [
{"url": "https://{region}.sentry.io"}
]
},
"delete": {
Expand Down
3 changes: 3 additions & 0 deletions api-docs/paths/releases/project-release-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@
{
"auth_token": ["project:releases"]
}
],
"servers": [
{"url": "https://{region}.sentry.io"}
]
}
}
3 changes: 3 additions & 0 deletions api-docs/paths/releases/release-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@
{
"auth_token": ["project:releases"]
}
],
"servers": [
{"url": "https://{region}.sentry.io"}
]
}
}
13 changes: 12 additions & 1 deletion src/sentry/conf/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,18 @@ def custom_parameter_sort(parameter: dict) -> tuple[str, int]:
"PARSER_WHITELIST": ["rest_framework.parsers.JSONParser"],
"POSTPROCESSING_HOOKS": ["sentry.apidocs.hooks.custom_postprocessing_hook"],
"PREPROCESSING_HOOKS": ["sentry.apidocs.hooks.custom_preprocessing_hook"],
"SERVERS": [{"url": "https://us.sentry.io"}, {"url": "https://de.sentry.io"}],
"SERVERS": [
{
"url": "https://{region}.sentry.io",
"variables": {
"region": {
"default": "us",
"description": "The data-storage-location for an organization",
"enum": ["us", "de"],
},
},
},
],
"SORT_OPERATION_PARAMETERS": custom_parameter_sort,
"TAGS": OPENAPI_TAGS,
"TITLE": "API Reference",
Expand Down
2 changes: 1 addition & 1 deletion tests/apidocs/endpoints/projects/test_dsyms.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ def test_post(self):
data,
format="multipart",
)
request = RequestFactory().post(self.url, data)
request = RequestFactory().post(self.url, data, SERVER_NAME="de.sentry.io", secure=True)

self.validate_schema(request, response)
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ def test_post(self):
data,
format="multipart",
)
request = RequestFactory().post(self.url, data=data, content_type="multipart/form-data")
request = RequestFactory().post(
self.url,
data=data,
content_type="multipart/form-data",
SERVER_NAME="us.sentry.io",
secure=True,
)

self.validate_schema(request, response)
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ def test_post(self):
data,
format="multipart",
)
request = RequestFactory().post(self.url, data=data, content_type="multipart/form-data")
request = RequestFactory().post(
self.url,
data=data,
content_type="multipart/form-data",
SERVER_NAME="us.sentry.io",
secure=True,
)

self.validate_schema(request, response)

0 comments on commit 88fd57c

Please sign in to comment.