Skip to content

Commit

Permalink
feat(api) Add ability for endpoint specific domains (#12168)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
markstory authored Dec 17, 2024
1 parent bd8d23b commit 984b323
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/build/open-api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ type Tag = {
'x-sidebar-name': string;
};

type ServerMeta = {
description: string;
url: string;
};

export type DeRefedOpenAPI = {
paths: {
[key: string]: {
Expand Down Expand Up @@ -66,6 +71,7 @@ export type DeRefedOpenAPI = {
tags: string[];
description?: string;
security?: any;
servers?: ServerMeta[];
};
};
};
Expand Down
6 changes: 6 additions & 0 deletions src/build/resolveOpenAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export type API = {
pathParameters: APIParameter[];
queryParameters: APIParameter[];
responses: APIResponse[];
server: string;
slug: string;
bodyContentType?: string;
descriptionMarkdown?: string;
Expand Down Expand Up @@ -120,11 +121,16 @@ async function apiCategoriesUncached(): Promise<APICategory[]> {

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,
Expand Down
2 changes: 1 addition & 1 deletion src/components/apiExamples/apiExamples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <auth_token>'`,
];
if (['put', 'options', 'delete'].includes(api.method.toLowerCase())) {
Expand Down

0 comments on commit 984b323

Please sign in to comment.