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

feat(api) Add ability for endpoint specific domains #12168

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
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
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
Loading