diff --git a/components/rest/RestOperation.tsx b/components/rest/RestOperation.tsx
index 8572ccf6bb..882e6f7f2c 100644
--- a/components/rest/RestOperation.tsx
+++ b/components/rest/RestOperation.tsx
@@ -6,6 +6,8 @@ import { RestResponse } from './RestResponse'
import { Operation } from './types'
import { RestNotes } from './RestNotes'
import { RestPreviewNotice } from './RestPreviewNotice'
+import { useTranslation } from 'components/hooks/useTranslation'
+import { RestStatusCodes } from './RestStatusCodes'
type Props = {
operation: Operation
@@ -13,7 +15,11 @@ type Props = {
}
export function RestOperation({ operation }: Props) {
+ const { t } = useTranslation('products')
const previews = operation['x-github'].previews
+ const nonErrorResponses = operation.responses.filter(
+ (response) => parseInt(response.httpStatusCode) < 400
+ )
return (
@@ -34,7 +40,7 @@ export function RestOperation({ operation }: Props) {
{operation['x-codeSamples'] && operation['x-codeSamples'].length > 0 && (
)}
-
+
{(operation.notes.length > 0 || operation['x-github'].enabledForGitHubApps) && (
)}
-
+
)
}
diff --git a/components/rest/RestResponse.tsx b/components/rest/RestResponse.tsx
index ea89589579..0d3f7c97ec 100644
--- a/components/rest/RestResponse.tsx
+++ b/components/rest/RestResponse.tsx
@@ -1,44 +1,20 @@
import { CodeResponse } from './types'
import { CodeBlock } from './CodeBlock'
-import { useTranslation } from 'components/hooks/useTranslation'
-import { RestResponseTable } from './RestResponseTable'
type Props = {
responses: Array
- variant?: 'non-error' | 'error'
}
export function RestResponse(props: Props) {
- const { responses, variant = 'non-error' } = props
- const { t } = useTranslation('products')
+ const { responses } = props
if (!responses || responses.length === 0) {
return null
}
- const filteredResponses = responses.filter((response) => {
- const responseCode = parseInt(response.httpStatusCode)
-
- if (variant === 'error') {
- return responseCode >= 400
- } else {
- return responseCode < 400
- }
- })
-
- if (filteredResponses.length === 0) {
- return null
- }
-
- if (variant === 'error') {
- return (
-
- )
- }
-
return (
<>
- {filteredResponses.map((response, index) => {
+ {responses.map((response, index) => {
return (
diff --git a/components/rest/RestResponseTable.module.scss b/components/rest/RestResponseTable.module.scss
index cf933c580c..eb86817a7b 100644
--- a/components/rest/RestResponseTable.module.scss
+++ b/components/rest/RestResponseTable.module.scss
@@ -8,6 +8,7 @@
th {
border: 0;
font-weight: normal;
+ background-color: transparent;
}
th:first-child {
diff --git a/components/rest/RestResponseTable.tsx b/components/rest/RestStatusCodes.tsx
similarity index 51%
rename from components/rest/RestResponseTable.tsx
rename to components/rest/RestStatusCodes.tsx
index f6a2f4e500..aa04886e03 100644
--- a/components/rest/RestResponseTable.tsx
+++ b/components/rest/RestStatusCodes.tsx
@@ -8,7 +8,7 @@ type Props = {
responses: Array
}
-export function RestResponseTable({ heading, responses }: Props) {
+export function RestStatusCodes({ heading, responses }: Props) {
const { t } = useTranslation('products')
return (
@@ -22,22 +22,21 @@ export function RestResponseTable({ heading, responses }: Props) {
- {responses.map((response, index) => {
- return (
-
-
- {response.httpStatusCode}
- |
-
- {response.description ? (
-
- ) : (
- response.httpStatusMessage
- )}
- |
-
- )
- })}
+ {responses.map((response, index) => (
+
+
+ {response.httpStatusCode}
+ |
+
+ {response.description &&
+ response.description.toLowerCase() !== ' response ' ? (
+
+ ) : (
+ response.httpStatusMessage
+ )}
+ |
+
+ ))}
>
diff --git a/data/ui.yml b/data/ui.yml
index 852e0c769e..3d2bb36ace 100644
--- a/data/ui.yml
+++ b/data/ui.yml
@@ -113,7 +113,7 @@ products:
notes: Notes
parameters: Parameters
response: Response
- error_codes: Error Codes
+ status_codes: Status codes
http_status_code: HTTP Status Code
code_sample: Code sample
code_samples: Code samples