diff --git a/src/build/open-api/types.ts b/src/build/open-api/types.ts index b2761cf2c967fe..5bc9a7c934af5b 100644 --- a/src/build/open-api/types.ts +++ b/src/build/open-api/types.ts @@ -36,6 +36,11 @@ type Tag = { 'x-sidebar-name': string; }; +type ServerMeta = { + description: string; + url: string; +}; + export type DeRefedOpenAPI = { paths: { [key: string]: { @@ -66,6 +71,7 @@ export type DeRefedOpenAPI = { tags: string[]; description?: string; security?: any; + servers?: ServerMeta[]; }; }; }; diff --git a/src/build/resolveOpenAPI.ts b/src/build/resolveOpenAPI.ts index 820b75a7cf31ad..1f2aa9b33b14cb 100644 --- a/src/build/resolveOpenAPI.ts +++ b/src/build/resolveOpenAPI.ts @@ -70,6 +70,7 @@ export type API = { pathParameters: APIParameter[]; queryParameters: APIParameter[]; responses: APIResponse[]; + server: string; slug: string; bodyContentType?: string; descriptionMarkdown?: string; @@ -120,11 +121,16 @@ async function apiCategoriesUncached(): Promise { Object.entries(data.paths).forEach(([apiPath, methods]) => { Object.entries(methods).forEach(([method, apiData]) => { + let server = 'https://sentry.io'; + if (apiData.servers && apiData.servers[0]) { + server = apiData.servers[0].url; + } apiData.tags.forEach(tag => { categoryMap[tag].apis.push({ apiPath, method, name: apiData.operationId, + server, slug: slugify(apiData.operationId), summary: apiData.summary, descriptionMarkdown: apiData.description, diff --git a/src/components/apiExamples/apiExamples.tsx b/src/components/apiExamples/apiExamples.tsx index cc5b026aeb0051..8c3248bca202cb 100644 --- a/src/components/apiExamples/apiExamples.tsx +++ b/src/components/apiExamples/apiExamples.tsx @@ -38,7 +38,7 @@ const codeToJsx = (code: string, lang = 'json') => { export function ApiExamples({api}: Props) { const apiExample = [ - `curl https://sentry.io${api.apiPath}`, + `curl ${api.server}${api.apiPath}`, ` -H 'Authorization: Bearer '`, ]; if (['put', 'options', 'delete'].includes(api.method.toLowerCase())) {