Skip to content

Commit 984b323

Browse files
authored
feat(api) Add ability for endpoint specific domains (#12168)
Some of our endpoints require customers to use region domains in order to have APIs work correctly across DE and US regions. I've already updated those endpoints in getsentry/sentry#82159. Refs getsentry/sentry#81232
1 parent bd8d23b commit 984b323

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/build/open-api/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ type Tag = {
3636
'x-sidebar-name': string;
3737
};
3838

39+
type ServerMeta = {
40+
description: string;
41+
url: string;
42+
};
43+
3944
export type DeRefedOpenAPI = {
4045
paths: {
4146
[key: string]: {
@@ -66,6 +71,7 @@ export type DeRefedOpenAPI = {
6671
tags: string[];
6772
description?: string;
6873
security?: any;
74+
servers?: ServerMeta[];
6975
};
7076
};
7177
};

src/build/resolveOpenAPI.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export type API = {
7070
pathParameters: APIParameter[];
7171
queryParameters: APIParameter[];
7272
responses: APIResponse[];
73+
server: string;
7374
slug: string;
7475
bodyContentType?: string;
7576
descriptionMarkdown?: string;
@@ -120,11 +121,16 @@ async function apiCategoriesUncached(): Promise<APICategory[]> {
120121

121122
Object.entries(data.paths).forEach(([apiPath, methods]) => {
122123
Object.entries(methods).forEach(([method, apiData]) => {
124+
let server = 'https://sentry.io';
125+
if (apiData.servers && apiData.servers[0]) {
126+
server = apiData.servers[0].url;
127+
}
123128
apiData.tags.forEach(tag => {
124129
categoryMap[tag].apis.push({
125130
apiPath,
126131
method,
127132
name: apiData.operationId,
133+
server,
128134
slug: slugify(apiData.operationId),
129135
summary: apiData.summary,
130136
descriptionMarkdown: apiData.description,

src/components/apiExamples/apiExamples.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const codeToJsx = (code: string, lang = 'json') => {
3838

3939
export function ApiExamples({api}: Props) {
4040
const apiExample = [
41-
`curl https://sentry.io${api.apiPath}`,
41+
`curl ${api.server}${api.apiPath}`,
4242
` -H 'Authorization: Bearer <auth_token>'`,
4343
];
4444
if (['put', 'options', 'delete'].includes(api.method.toLowerCase())) {

0 commit comments

Comments
 (0)