noCopy?: boolean;
render?: string;
snippet: string | Array<string | undefined>;
- wrap?: boolean;
+ wrap?: boolean | 'words';
}
// keep this "useless" concatenation for the readability reason
className?: string;
htmlAsString: string;
language?: string;
- wrap?: boolean;
+ wrap?: boolean | 'words';
}
const CODE_REGEXP = '<(code|pre)\\b([^>]*?)>(.+?)<\\/\\1>';
return (
<StyledSpan
- className={classNames(`hljs ${className ?? ''}`, { 'code-wrap': wrap })}
+ className={classNames(
+ `hljs ${className ?? ''}`,
+ { 'code-wrap': wrap },
+ { 'wrap-words': wrap === 'words' },
+ )}
// Safe: value is escaped by highlight.js
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: highlightedHtmlAsString }}
&.code-wrap {
${tw`sw-whitespace-pre-wrap`}
${tw`sw-break-all`}
+
+ &.wrap-words {
+ word-break: normal;
+ ${tw`sw-break-words`}
+ }
}
mark {
word-break: break-all;
}
+.emotion-6.code-wrap.wrap-words {
+ word-break: normal;
+ overflow-wrap: break-word;
+}
+
.emotion-6 mark {
font-weight: 400;
padding: 0.25rem;
word-break: break-all;
}
+.emotion-6.code-wrap.wrap-words {
+ word-break: normal;
+ overflow-wrap: break-word;
+}
+
.emotion-6 mark {
font-weight: 400;
padding: 0.25rem;
word-break: break-all;
}
+.emotion-6.code-wrap.wrap-words {
+ word-break: normal;
+ overflow-wrap: break-word;
+}
+
.emotion-6 mark {
font-weight: 400;
padding: 0.25rem;
expect(ui.requestHeader.query()).not.toBeInTheDocument();
expect(ui.requestBody.query()).not.toBeInTheDocument();
expect(ui.queryParameter.getAll()).toHaveLength(1);
- expect(ui.queryParameter.getAt(0)).toHaveTextContent('status ["available","pending","sold"]');
+ expect(ui.queryParameter.getAt(0)).toHaveTextContent(
+ 'status Enum (string): available, pending, sold',
+ );
expect(ui.queryParameter.getAt(0)).not.toHaveTextContent('default: available');
await user.click(ui.queryParameter.byRole('button').getAt(0));
expect(ui.queryParameter.getAt(0)).toHaveTextContent('default: available');
type: 'string',
enum: ['GREEN', 'YELLOW', 'RED'],
}),
- ).toStrictEqual(['GREEN', 'YELLOW', 'RED']);
+ ).toStrictEqual('Enum (string): GREEN, YELLOW, RED');
});
import { groupBy } from 'lodash';
import { OpenAPIV3 } from 'openapi-types';
import React from 'react';
+import { FormattedMessage } from 'react-intl';
import { translate } from '../../../helpers/l10n';
import { ExcludeReferences } from '../types';
import { mapOpenAPISchema } from '../utils';
open={openParameters.includes(parameter.name)}
>
<div>{parameter.description}</div>
+ {parameter.schema?.enum && (
+ <div className="sw-mt-2">
+ <FormattedMessage
+ id="api_documentation.v2.enum_description"
+ values={{
+ values: (
+ <div className="sw-body-sm-highlight">
+ {parameter.schema.enum.join(', ')}
+ </div>
+ ),
+ }}
+ />
+ </div>
+ )}
{parameter.schema?.maximum && (
<TextMuted
className="sw-mt-2 sw-block"
import { isEmpty } from 'lodash';
import { OpenAPIV3 } from 'openapi-types';
import React from 'react';
+import { FormattedMessage } from 'react-intl';
import { translate } from '../../../helpers/l10n';
import { ExcludeReferences } from '../types';
open={openParameters.includes(key)}
>
<div>{parameters[key].description}</div>
+ {parameters[key].enum && (
+ <div className="sw-mt-2">
+ <FormattedMessage
+ id="api_documentation.v2.enum_description"
+ values={{
+ values: <i>{parameters[key].enum?.join(', ')}</i>,
+ }}
+ />
+ </div>
+ )}
{parameters[key].maxLength && (
<TextMuted
className="sw-mt-2 sw-block"
content?: Exclude<ExcludeReferences<OpenAPIV3.ResponseObject>['content'], undefined>;
}
-export default function ApiResponseSchema(props: Props) {
+export default function ApiResponseSchema(props: Readonly<Props>) {
const { content, ...other } = props;
const schema =
content &&
language="json"
className="sw-p-6"
snippet={JSON.stringify(mapOpenAPISchema(schema), null, 2)}
- wrap
+ wrap="words"
{...other}
/>
);
if (schema.type === 'array') {
return [mapOpenAPISchema(schema.items)];
}
- if (schema.type === 'string' && schema.enum) {
- return schema.enum as ConvertedSchema;
+ if (schema.enum) {
+ return `Enum (${schema.type}): ${(schema.enum as ConvertedSchema[]).join(', ')}`;
}
if (schema.format) {
return `${schema.type} (${schema.format})`;
api_documentation.v2.request_subheader.path=Path Parameters
api_documentation.v2.request_subheader.header=Headers
api_documentation.v2.request_subheader.request_body=Request Body
+api_documentation.v2.enum_description=Valid values: {values}
#------------------------------------------------------------------------------