feat: add support x-enumDescriptions

This commit is contained in:
Alex Varchuk 2025-01-15 18:24:13 +01:00
parent c8eb5aa7ec
commit 417b934ffc
No known key found for this signature in database
GPG Key ID: 8A9260AE529FF454
13 changed files with 251 additions and 100 deletions

View File

@ -1083,6 +1083,10 @@ components:
- available
- pending
- sold
x-enumDescriptions:
available: Available status
pending: Pending status
sold: Sold status
petType:
description: Type of a pet
type: string

View File

@ -5,17 +5,29 @@ import { l } from '../../services/Labels';
import { OptionsContext } from '../OptionsProvider';
import styled from '../../styled-components';
import { RedocRawOptions } from '../../services/RedocNormalizedOptions';
import { StyledMarkdownBlock } from '../Markdown/styled.elements';
import { Markdown } from '../Markdown/Markdown';
export interface EnumValuesProps {
values: string[];
isArrayType: boolean;
values?: string[] | { [name: string]: string };
type: string | string[];
}
export interface EnumValuesState {
collapsed: boolean;
}
const DescriptionEnumsBlock = styled(StyledMarkdownBlock)`
table {
margin-bottom: 0.2em;
}
`;
export class EnumValues extends React.PureComponent<EnumValuesProps, EnumValuesState> {
constructor(props: EnumValuesProps) {
super(props);
this.toggle = this.toggle.bind(this);
}
state: EnumValuesState = {
collapsed: true,
};
@ -27,54 +39,94 @@ export class EnumValues extends React.PureComponent<EnumValuesProps, EnumValuesS
}
render() {
const { values, isArrayType } = this.props;
const { values, type } = this.props;
const { collapsed } = this.state;
const isDescriptionEnum = !Array.isArray(values);
const enums =
(Array.isArray(values) && values) ||
Object.entries(values || {}).map(([value, description]) => ({
value,
description,
}));
// TODO: provide context interface in more elegant way
const { enumSkipQuotes, maxDisplayedEnumValues } = this.context as RedocRawOptions;
if (!values.length) {
if (!enums.length) {
return null;
}
const displayedItems =
this.state.collapsed && maxDisplayedEnumValues
? values.slice(0, maxDisplayedEnumValues)
: values;
? enums.slice(0, maxDisplayedEnumValues)
: enums;
const showToggleButton = maxDisplayedEnumValues
? values.length > maxDisplayedEnumValues
: false;
const showToggleButton = maxDisplayedEnumValues ? enums.length > maxDisplayedEnumValues : false;
const toggleButtonText = maxDisplayedEnumValues
? collapsed
? `${values.length - maxDisplayedEnumValues} more`
? `${enums.length - maxDisplayedEnumValues} more`
: 'Hide'
: '';
return (
<div>
<FieldLabel>
{isArrayType ? l('enumArray') : ''}{' '}
{values.length === 1 ? l('enumSingleValue') : l('enum')}:
</FieldLabel>{' '}
{displayedItems.map((value, idx) => {
const exampleValue = enumSkipQuotes ? String(value) : JSON.stringify(value);
return (
<React.Fragment key={idx}>
<ExampleValue>{exampleValue}</ExampleValue>{' '}
</React.Fragment>
);
})}
{showToggleButton ? (
<ToggleButton
onClick={() => {
this.toggle();
}}
>
{toggleButtonText}
</ToggleButton>
) : null}
{isDescriptionEnum ? (
<>
<DescriptionEnumsBlock>
<table>
<thead>
<tr>
<th>
<FieldLabel>
{type === 'array' ? l('enumArray') : ''}{' '}
{enums.length === 1 ? l('enumSingleValue') : l('enum')}
</FieldLabel>{' '}
</th>
<th>
<strong>Description</strong>
</th>
</tr>
</thead>
<tbody>
{(displayedItems as { value: string; description: string }[]).map(
({ description, value }) => {
return (
<tr key={value}>
<td>{value}</td>
<td>
<Markdown source={description} compact inline />
</td>
</tr>
);
},
)}
</tbody>
</table>
</DescriptionEnumsBlock>
{showToggleButton ? (
<ToggleButton onClick={this.toggle}>{toggleButtonText}</ToggleButton>
) : null}
</>
) : (
<>
<FieldLabel>
{type === 'array' ? l('enumArray') : ''}{' '}
{values.length === 1 ? l('enumSingleValue') : l('enum')}:
</FieldLabel>{' '}
{displayedItems.map((value, idx) => {
const exampleValue = enumSkipQuotes ? String(value) : JSON.stringify(value);
return (
<React.Fragment key={idx}>
<ExampleValue>{exampleValue}</ExampleValue>{' '}
</React.Fragment>
);
})}
{showToggleButton ? (
<ToggleButton onClick={this.toggle}>{toggleButtonText}</ToggleButton>
) : null}
</>
)}
</div>
);
}

View File

@ -99,7 +99,7 @@ export const FieldDetailsComponent = observer((props: FieldProps) => {
)}
<FieldDetail raw={rawDefault} label={l('default') + ':'} value={defaultValue} />
{!renderDiscriminatorSwitch && (
<EnumValues isArrayType={isArrayType} values={schema.enum} />
<EnumValues type={schema.type} values={schema['x-enumDescriptions'] || schema.enum} />
)}{' '}
{renderedExamples}
<Extensions extensions={{ ...extensions, ...schema.extensions }} />

View File

@ -79,12 +79,13 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"disableSearch": false,
"downloadDefinitionUrl": undefined,
"downloadFileName": undefined,
"downloadUrls": undefined,
"enumSkipQuotes": false,
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"hideDownloadButton": false,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
"hideRequestPayloadSample": false,
@ -93,7 +94,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"hideSecuritySection": false,
"hideSingleRequestSampleTab": false,
"ignoreNamedSchemas": Set {},
"jsonSampleExpandLevel": 2,
"jsonSamplesExpandLevel": 2,
"maxDisplayedEnumValues": undefined,
"menuToggle": true,
"minCharacterLengthToInitSearch": 3,
@ -102,8 +103,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"onlyRequiredInSamples": false,
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"requiredPropsFirst": false,
"schemaExpansionLevel": 0,
"sanitize": false,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
"showObjectSchemaExamples": false,
@ -114,6 +115,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"sortEnumValuesAlphabetically": false,
"sortOperationsAlphabetically": false,
"sortPropsAlphabetically": false,
"sortRequiredPropsFirst": false,
"sortTagsAlphabetically": false,
"theme": {
"breakpoints": {
@ -292,7 +294,6 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
},
},
"unstable_ignoreMimeParameters": false,
"untrustedSpec": false,
},
"pattern": undefined,
"pointer": "#/components/schemas/Dog/properties/packSize",
@ -313,6 +314,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"type": "number",
"typePrefix": "",
"writeOnly": false,
"x-enumDescriptions": undefined,
},
},
FieldModel {
@ -351,12 +353,13 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"disableSearch": false,
"downloadDefinitionUrl": undefined,
"downloadFileName": undefined,
"downloadUrls": undefined,
"enumSkipQuotes": false,
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"hideDownloadButton": false,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
"hideRequestPayloadSample": false,
@ -365,7 +368,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"hideSecuritySection": false,
"hideSingleRequestSampleTab": false,
"ignoreNamedSchemas": Set {},
"jsonSampleExpandLevel": 2,
"jsonSamplesExpandLevel": 2,
"maxDisplayedEnumValues": undefined,
"menuToggle": true,
"minCharacterLengthToInitSearch": 3,
@ -374,8 +377,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"onlyRequiredInSamples": false,
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"requiredPropsFirst": false,
"schemaExpansionLevel": 0,
"sanitize": false,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
"showObjectSchemaExamples": false,
@ -386,6 +389,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"sortEnumValuesAlphabetically": false,
"sortOperationsAlphabetically": false,
"sortPropsAlphabetically": false,
"sortRequiredPropsFirst": false,
"sortTagsAlphabetically": false,
"theme": {
"breakpoints": {
@ -564,7 +568,6 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
},
},
"unstable_ignoreMimeParameters": false,
"untrustedSpec": false,
},
"pattern": undefined,
"pointer": "#/components/schemas/Dog/properties/type",
@ -597,6 +600,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"type": "string",
"typePrefix": "",
"writeOnly": false,
"x-enumDescriptions": undefined,
},
},
],
@ -610,12 +614,13 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"disableSearch": false,
"downloadDefinitionUrl": undefined,
"downloadFileName": undefined,
"downloadUrls": undefined,
"enumSkipQuotes": false,
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"hideDownloadButton": false,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
"hideRequestPayloadSample": false,
@ -624,7 +629,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"hideSecuritySection": false,
"hideSingleRequestSampleTab": false,
"ignoreNamedSchemas": Set {},
"jsonSampleExpandLevel": 2,
"jsonSamplesExpandLevel": 2,
"maxDisplayedEnumValues": undefined,
"menuToggle": true,
"minCharacterLengthToInitSearch": 3,
@ -633,8 +638,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"onlyRequiredInSamples": false,
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"requiredPropsFirst": false,
"schemaExpansionLevel": 0,
"sanitize": false,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
"showObjectSchemaExamples": false,
@ -645,6 +650,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"sortEnumValuesAlphabetically": false,
"sortOperationsAlphabetically": false,
"sortPropsAlphabetically": false,
"sortRequiredPropsFirst": false,
"sortTagsAlphabetically": false,
"theme": {
"breakpoints": {
@ -823,7 +829,6 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
},
},
"unstable_ignoreMimeParameters": false,
"untrustedSpec": false,
},
"pattern": undefined,
"pointer": "#/components/schemas/Dog",
@ -878,6 +883,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"type": "object",
"typePrefix": "",
"writeOnly": false,
"x-enumDescriptions": undefined,
},
SchemaModel {
"activeOneOf": 0,
@ -931,12 +937,13 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"disableSearch": false,
"downloadDefinitionUrl": undefined,
"downloadFileName": undefined,
"downloadUrls": undefined,
"enumSkipQuotes": false,
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"hideDownloadButton": false,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
"hideRequestPayloadSample": false,
@ -945,7 +952,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"hideSecuritySection": false,
"hideSingleRequestSampleTab": false,
"ignoreNamedSchemas": Set {},
"jsonSampleExpandLevel": 2,
"jsonSamplesExpandLevel": 2,
"maxDisplayedEnumValues": undefined,
"menuToggle": true,
"minCharacterLengthToInitSearch": 3,
@ -954,8 +961,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"onlyRequiredInSamples": false,
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"requiredPropsFirst": false,
"schemaExpansionLevel": 0,
"sanitize": false,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
"showObjectSchemaExamples": false,
@ -966,6 +973,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"sortEnumValuesAlphabetically": false,
"sortOperationsAlphabetically": false,
"sortPropsAlphabetically": false,
"sortRequiredPropsFirst": false,
"sortTagsAlphabetically": false,
"theme": {
"breakpoints": {
@ -1144,7 +1152,6 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
},
},
"unstable_ignoreMimeParameters": false,
"untrustedSpec": false,
},
"pattern": undefined,
"pointer": "#/components/schemas/Cat/properties/type",
@ -1177,6 +1184,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"type": "string",
"typePrefix": "",
"writeOnly": false,
"x-enumDescriptions": undefined,
},
},
FieldModel {
@ -1215,12 +1223,13 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"disableSearch": false,
"downloadDefinitionUrl": undefined,
"downloadFileName": undefined,
"downloadUrls": undefined,
"enumSkipQuotes": false,
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"hideDownloadButton": false,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
"hideRequestPayloadSample": false,
@ -1229,7 +1238,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"hideSecuritySection": false,
"hideSingleRequestSampleTab": false,
"ignoreNamedSchemas": Set {},
"jsonSampleExpandLevel": 2,
"jsonSamplesExpandLevel": 2,
"maxDisplayedEnumValues": undefined,
"menuToggle": true,
"minCharacterLengthToInitSearch": 3,
@ -1238,8 +1247,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"onlyRequiredInSamples": false,
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"requiredPropsFirst": false,
"schemaExpansionLevel": 0,
"sanitize": false,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
"showObjectSchemaExamples": false,
@ -1250,6 +1259,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"sortEnumValuesAlphabetically": false,
"sortOperationsAlphabetically": false,
"sortPropsAlphabetically": false,
"sortRequiredPropsFirst": false,
"sortTagsAlphabetically": false,
"theme": {
"breakpoints": {
@ -1428,7 +1438,6 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
},
},
"unstable_ignoreMimeParameters": false,
"untrustedSpec": false,
},
"pattern": undefined,
"pointer": "#/components/schemas/Cat/properties/packSize",
@ -1457,6 +1466,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"type": "number",
"typePrefix": "",
"writeOnly": false,
"x-enumDescriptions": undefined,
},
},
],
@ -1470,12 +1480,13 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"disableSearch": false,
"downloadDefinitionUrl": undefined,
"downloadFileName": undefined,
"downloadUrls": undefined,
"enumSkipQuotes": false,
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"hideDownloadButton": false,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
"hideRequestPayloadSample": false,
@ -1484,7 +1495,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"hideSecuritySection": false,
"hideSingleRequestSampleTab": false,
"ignoreNamedSchemas": Set {},
"jsonSampleExpandLevel": 2,
"jsonSamplesExpandLevel": 2,
"maxDisplayedEnumValues": undefined,
"menuToggle": true,
"minCharacterLengthToInitSearch": 3,
@ -1493,8 +1504,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"onlyRequiredInSamples": false,
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"requiredPropsFirst": false,
"schemaExpansionLevel": 0,
"sanitize": false,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
"showObjectSchemaExamples": false,
@ -1505,6 +1516,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"sortEnumValuesAlphabetically": false,
"sortOperationsAlphabetically": false,
"sortPropsAlphabetically": false,
"sortRequiredPropsFirst": false,
"sortTagsAlphabetically": false,
"theme": {
"breakpoints": {
@ -1683,7 +1695,6 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
},
},
"unstable_ignoreMimeParameters": false,
"untrustedSpec": false,
},
"pattern": undefined,
"pointer": "#/components/schemas/Cat",
@ -1743,6 +1754,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"type": "object",
"typePrefix": "",
"writeOnly": false,
"x-enumDescriptions": undefined,
},
],
"options": RedocNormalizedOptions {
@ -1750,12 +1762,13 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"disableSearch": false,
"downloadDefinitionUrl": undefined,
"downloadFileName": undefined,
"downloadUrls": undefined,
"enumSkipQuotes": false,
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"hideDownloadButton": false,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
"hideRequestPayloadSample": false,
@ -1764,7 +1777,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"hideSecuritySection": false,
"hideSingleRequestSampleTab": false,
"ignoreNamedSchemas": Set {},
"jsonSampleExpandLevel": 2,
"jsonSamplesExpandLevel": 2,
"maxDisplayedEnumValues": undefined,
"menuToggle": true,
"minCharacterLengthToInitSearch": 3,
@ -1773,8 +1786,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"onlyRequiredInSamples": false,
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"requiredPropsFirst": false,
"schemaExpansionLevel": 0,
"sanitize": false,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
"showObjectSchemaExamples": false,
@ -1785,6 +1798,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"sortEnumValuesAlphabetically": false,
"sortOperationsAlphabetically": false,
"sortPropsAlphabetically": false,
"sortRequiredPropsFirst": false,
"sortTagsAlphabetically": false,
"theme": {
"breakpoints": {
@ -1963,7 +1977,6 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
},
},
"unstable_ignoreMimeParameters": false,
"untrustedSpec": false,
},
"pattern": undefined,
"pointer": "#/components/schemas/Pet",
@ -2003,6 +2016,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"type": "object",
"typePrefix": "",
"writeOnly": false,
"x-enumDescriptions": undefined,
},
}
}
@ -2060,12 +2074,13 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"disableSearch": false,
"downloadDefinitionUrl": undefined,
"downloadFileName": undefined,
"downloadUrls": undefined,
"enumSkipQuotes": false,
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"hideDownloadButton": false,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
"hideRequestPayloadSample": false,
@ -2074,7 +2089,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"hideSecuritySection": false,
"hideSingleRequestSampleTab": false,
"ignoreNamedSchemas": Set {},
"jsonSampleExpandLevel": 2,
"jsonSamplesExpandLevel": 2,
"maxDisplayedEnumValues": undefined,
"menuToggle": true,
"minCharacterLengthToInitSearch": 3,
@ -2083,8 +2098,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"onlyRequiredInSamples": false,
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"requiredPropsFirst": false,
"schemaExpansionLevel": 0,
"sanitize": false,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
"showObjectSchemaExamples": false,
@ -2095,6 +2110,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"sortEnumValuesAlphabetically": false,
"sortOperationsAlphabetically": false,
"sortPropsAlphabetically": false,
"sortRequiredPropsFirst": false,
"sortTagsAlphabetically": false,
"theme": {
"breakpoints": {
@ -2273,7 +2289,6 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
},
},
"unstable_ignoreMimeParameters": false,
"untrustedSpec": false,
},
"pattern": undefined,
"pointer": "#/components/schemas/Dog/properties/packSize",
@ -2294,6 +2309,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"type": "number",
"typePrefix": "",
"writeOnly": false,
"x-enumDescriptions": undefined,
},
},
FieldModel {
@ -2332,12 +2348,13 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"disableSearch": false,
"downloadDefinitionUrl": undefined,
"downloadFileName": undefined,
"downloadUrls": undefined,
"enumSkipQuotes": false,
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"hideDownloadButton": false,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
"hideRequestPayloadSample": false,
@ -2346,7 +2363,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"hideSecuritySection": false,
"hideSingleRequestSampleTab": false,
"ignoreNamedSchemas": Set {},
"jsonSampleExpandLevel": 2,
"jsonSamplesExpandLevel": 2,
"maxDisplayedEnumValues": undefined,
"menuToggle": true,
"minCharacterLengthToInitSearch": 3,
@ -2355,8 +2372,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"onlyRequiredInSamples": false,
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"requiredPropsFirst": false,
"schemaExpansionLevel": 0,
"sanitize": false,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
"showObjectSchemaExamples": false,
@ -2367,6 +2384,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"sortEnumValuesAlphabetically": false,
"sortOperationsAlphabetically": false,
"sortPropsAlphabetically": false,
"sortRequiredPropsFirst": false,
"sortTagsAlphabetically": false,
"theme": {
"breakpoints": {
@ -2545,7 +2563,6 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
},
},
"unstable_ignoreMimeParameters": false,
"untrustedSpec": false,
},
"pattern": undefined,
"pointer": "#/components/schemas/Dog/properties/type",
@ -2578,6 +2595,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"type": "string",
"typePrefix": "",
"writeOnly": false,
"x-enumDescriptions": undefined,
},
},
],
@ -2591,12 +2609,13 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"disableSearch": false,
"downloadDefinitionUrl": undefined,
"downloadFileName": undefined,
"downloadUrls": undefined,
"enumSkipQuotes": false,
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"hideDownloadButton": false,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
"hideRequestPayloadSample": false,
@ -2605,7 +2624,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"hideSecuritySection": false,
"hideSingleRequestSampleTab": false,
"ignoreNamedSchemas": Set {},
"jsonSampleExpandLevel": 2,
"jsonSamplesExpandLevel": 2,
"maxDisplayedEnumValues": undefined,
"menuToggle": true,
"minCharacterLengthToInitSearch": 3,
@ -2614,8 +2633,8 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"onlyRequiredInSamples": false,
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"requiredPropsFirst": false,
"schemaExpansionLevel": 0,
"sanitize": false,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
"showObjectSchemaExamples": false,
@ -2626,6 +2645,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"sortEnumValuesAlphabetically": false,
"sortOperationsAlphabetically": false,
"sortPropsAlphabetically": false,
"sortRequiredPropsFirst": false,
"sortTagsAlphabetically": false,
"theme": {
"breakpoints": {
@ -2804,7 +2824,6 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
},
},
"unstable_ignoreMimeParameters": false,
"untrustedSpec": false,
},
"pattern": undefined,
"pointer": "#/components/schemas/Dog",
@ -2859,6 +2878,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"type": "object",
"typePrefix": "",
"writeOnly": false,
"x-enumDescriptions": undefined,
}
}
/>
@ -2921,6 +2941,7 @@ exports[`Components SchemaView discriminator should correctly render discriminat
"type": "number",
"typePrefix": "",
"writeOnly": false,
"x-enumDescriptions": undefined,
},
}
}
@ -2994,6 +3015,7 @@ exports[`Components SchemaView discriminator should correctly render discriminat
"type": "string",
"typePrefix": "",
"writeOnly": false,
"x-enumDescriptions": undefined,
},
}
}

View File

@ -159,7 +159,7 @@ exports[`FieldDetailsComponent renders correctly when field items have string ty
</span>
</span>
<span
class="sc-kpDqfm sc-dAlyuH sc-dxcDKg cGRfjn gHomYR gXntsr"
class="sc-kpDqfm sc-dAlyuH sc-gvZAcH cGRfjn gHomYR eXivNJ"
>
[ items
<span>

View File

@ -3,21 +3,21 @@
exports[`SecurityRequirement should render SecurityDefs 1`] = `
"<div id="section/Authentication/petstore_auth" data-section-id="section/Authentication/petstore_auth" class="sc-dcJsrY bBkGhy"><div class="sc-kAyceB hBQWIZ"><div class="sc-fqkvVR oJKYx"><h2 class="sc-jXbUNg fWnwAh">petstore_auth</h2><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><p>Get access to data while protecting your account credentials.
OAuth2 is also a safer and more secure way to give you access.</p>
</div><div class="sc-ejfMa-d a-DjBE"><div class="sc-dkmUuB hFwAIA"><b>Security Scheme Type: </b><span>OAuth2</span></div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-dkmUuB hFwAIA"><b>Flow type: </b><code>implicit </code></div><div class="sc-dkmUuB hFwAIA"><strong> Authorization URL: </strong><code><a target="_blank" rel="noopener noreferrer" href="http://petstore.swagger.io/api/oauth/dialog">http://petstore.swagger.io/api/oauth/dialog</a></code></div><div class="sc-dkmUuB hFwAIA"><b> Scopes: </b></div><div class="sc-iEXKAA blExNw container" style="height: 4em;"><ul><li><code>write:pets</code> - <div class="sc-eeDRCY sc-eBMEME sc-fhzFiK gTGgei iCmQdS hXtrri redoc-markdown"><p>modify pets in your account</p>
</div><div class="sc-iEXKAA ebCiwb"><div class="sc-ejfMa-d bdDYxc"><b>Security Scheme Type: </b><span>OAuth2</span></div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-ejfMa-d bdDYxc"><b>Flow type: </b><code>implicit </code></div><div class="sc-ejfMa-d bdDYxc"><strong> Authorization URL: </strong><code><a target="_blank" rel="noopener noreferrer" href="http://petstore.swagger.io/api/oauth/dialog">http://petstore.swagger.io/api/oauth/dialog</a></code></div><div class="sc-ejfMa-d bdDYxc"><b> Scopes: </b></div><div class="sc-EgOXT kRIdPi container" style="height: 4em;"><ul><li><code>write:pets</code> - <div class="sc-eeDRCY sc-eBMEME sc-fhzFiK gTGgei iCmQdS hXtrri redoc-markdown"><p>modify pets in your account</p>
</div></li><li><code>read:pets</code> - <div class="sc-eeDRCY sc-eBMEME sc-fhzFiK gTGgei iCmQdS hXtrri redoc-markdown"><p>read your pets</p>
</div></li></ul></div><div class="sc-EgOXT bNSpXO"></div></div></div></div></div></div><div id="section/Authentication/GitLab_PersonalAccessToken" data-section-id="section/Authentication/GitLab_PersonalAccessToken" class="sc-dcJsrY bBkGhy"><div class="sc-kAyceB hBQWIZ"><div class="sc-fqkvVR oJKYx"><h2 class="sc-jXbUNg fWnwAh">GitLab_PersonalAccessToken</h2><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><p>GitLab Personal Access Token description</p>
</div><div class="sc-ejfMa-d a-DjBE"><div class="sc-dkmUuB hFwAIA"><b>Security Scheme Type: </b><span>API Key</span></div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-dkmUuB hFwAIA"><b>Header parameter name: </b><code>PRIVATE-TOKEN</code></div></div></div></div></div></div><div id="section/Authentication/GitLab_OpenIdConnect" data-section-id="section/Authentication/GitLab_OpenIdConnect" class="sc-dcJsrY bBkGhy"><div class="sc-kAyceB hBQWIZ"><div class="sc-fqkvVR oJKYx"><h2 class="sc-jXbUNg fWnwAh">GitLab_OpenIdConnect</h2><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><p>GitLab OpenIdConnect description</p>
</div><div class="sc-ejfMa-d a-DjBE"><div class="sc-dkmUuB hFwAIA"><b>Security Scheme Type: </b><span>OpenID Connect</span></div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-dkmUuB hFwAIA"><b>Connect URL: </b><code><a target="_blank" rel="noopener noreferrer" href="https://gitlab.com/.well-known/openid-configuration">https://gitlab.com/.well-known/openid-configuration</a></code></div></div></div></div></div></div><div id="section/Authentication/basicAuth" data-section-id="section/Authentication/basicAuth" class="sc-dcJsrY bBkGhy"><div class="sc-kAyceB hBQWIZ"><div class="sc-fqkvVR oJKYx"><h2 class="sc-jXbUNg fWnwAh">basicAuth</h2><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"></div><div class="sc-ejfMa-d a-DjBE"><div class="sc-dkmUuB hFwAIA"><b>Security Scheme Type: </b><span>HTTP</span></div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-dkmUuB hFwAIA"><b>HTTP Authorization Scheme: </b><code>basic</code></div><div class="sc-dkmUuB hFwAIA"></div></div></div></div></div></div>"
</div></li></ul></div><div class="sc-eZYNyq dIKkVb"></div></div></div></div></div></div><div id="section/Authentication/GitLab_PersonalAccessToken" data-section-id="section/Authentication/GitLab_PersonalAccessToken" class="sc-dcJsrY bBkGhy"><div class="sc-kAyceB hBQWIZ"><div class="sc-fqkvVR oJKYx"><h2 class="sc-jXbUNg fWnwAh">GitLab_PersonalAccessToken</h2><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><p>GitLab Personal Access Token description</p>
</div><div class="sc-iEXKAA ebCiwb"><div class="sc-ejfMa-d bdDYxc"><b>Security Scheme Type: </b><span>API Key</span></div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-ejfMa-d bdDYxc"><b>Header parameter name: </b><code>PRIVATE-TOKEN</code></div></div></div></div></div></div><div id="section/Authentication/GitLab_OpenIdConnect" data-section-id="section/Authentication/GitLab_OpenIdConnect" class="sc-dcJsrY bBkGhy"><div class="sc-kAyceB hBQWIZ"><div class="sc-fqkvVR oJKYx"><h2 class="sc-jXbUNg fWnwAh">GitLab_OpenIdConnect</h2><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><p>GitLab OpenIdConnect description</p>
</div><div class="sc-iEXKAA ebCiwb"><div class="sc-ejfMa-d bdDYxc"><b>Security Scheme Type: </b><span>OpenID Connect</span></div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-ejfMa-d bdDYxc"><b>Connect URL: </b><code><a target="_blank" rel="noopener noreferrer" href="https://gitlab.com/.well-known/openid-configuration">https://gitlab.com/.well-known/openid-configuration</a></code></div></div></div></div></div></div><div id="section/Authentication/basicAuth" data-section-id="section/Authentication/basicAuth" class="sc-dcJsrY bBkGhy"><div class="sc-kAyceB hBQWIZ"><div class="sc-fqkvVR oJKYx"><h2 class="sc-jXbUNg fWnwAh">basicAuth</h2><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"></div><div class="sc-iEXKAA ebCiwb"><div class="sc-ejfMa-d bdDYxc"><b>Security Scheme Type: </b><span>HTTP</span></div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-ejfMa-d bdDYxc"><b>HTTP Authorization Scheme: </b><code>basic</code></div><div class="sc-ejfMa-d bdDYxc"></div></div></div></div></div></div>"
`;
exports[`SecurityRequirement should render authDefinition 1`] = `"<div class="sc-bDumWk iWBBny"><div class="sc-sLsrZ hgeUJn"><h5 class="sc-dAlyuH sc-fifgRP jbQuod kWJur">Authorizations:</h5><svg class="sc-cwHptR iZRiKW" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg></div><div class="sc-dBmzty eoFcYg"><span class="sc-kbousE cpXQuZ">(<span class="sc-gfoqjT kbvnry">API Key: <i>GitLab_PersonalAccessToken</i></span><span class="sc-gfoqjT kbvnry">OpenID Connect: <i>GitLab_OpenIdConnect</i></span><span class="sc-gfoqjT kbvnry">HTTP: <i>basicAuth</i></span>) </span><span class="sc-kbousE cpXQuZ"><span class="sc-gfoqjT kbvnry">OAuth2: <i>petstore_auth</i></span></span></div></div>,"`;
exports[`SecurityRequirement should render authDefinition 1`] = `"<div class="sc-dkmUuB fUBzjk"><div class="sc-dBmzty iDyBRL"><h5 class="sc-dAlyuH sc-bDumWk jbQuod feBYnB">Authorizations:</h5><svg class="sc-cwHptR iZRiKW" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg></div><div class="sc-fifgRP eqIYDA"><span class="sc-sLsrZ jmro">(<span class="sc-kbousE iMnLRS">API Key: <i>GitLab_PersonalAccessToken</i></span><span class="sc-kbousE iMnLRS">OpenID Connect: <i>GitLab_OpenIdConnect</i></span><span class="sc-kbousE iMnLRS">HTTP: <i>basicAuth</i></span>) </span><span class="sc-sLsrZ jmro"><span class="sc-kbousE iMnLRS">OAuth2: <i>petstore_auth</i></span></span></div></div>,"`;
exports[`SecurityRequirement should render authDefinition 2`] = `
"<div class="sc-bDumWk gtsPcy"><div class="sc-sLsrZ hgeUJn"><h5 class="sc-dAlyuH sc-fifgRP jbQuod kWJur">Authorizations:</h5><svg class="sc-cwHptR dSJqIk" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg></div><div class="sc-dBmzty llvZdI"><span class="sc-kbousE dOwJQz">(<span class="sc-gfoqjT kbvnry">API Key: <i>GitLab_PersonalAccessToken</i></span><span class="sc-gfoqjT kbvnry">OpenID Connect: <i>GitLab_OpenIdConnect</i></span><span class="sc-gfoqjT kbvnry">HTTP: <i>basicAuth</i></span>) </span><span class="sc-kbousE dOwJQz"><span class="sc-gfoqjT kbvnry">OAuth2: <i>petstore_auth</i> (<code class="sc-eyvILC bzHwfc">write:pets</code><code class="sc-eyvILC bzHwfc">read:pets</code>) </span></span></div></div><div class="sc-ejfMa-d a-DjBE"><h5><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="11" height="11"><path fill="currentColor" d="M18 10V6A6 6 0 0 0 6 6v4H3v14h18V10h-3zM8 6c0-2.206 1.794-4 4-4s4 1.794 4 4v4H8V6zm11 16H5V12h14v10z"></path></svg> OAuth2: petstore_auth</h5><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><p>Get access to data while protecting your account credentials.
"<div class="sc-dkmUuB KTEsk"><div class="sc-dBmzty iDyBRL"><h5 class="sc-dAlyuH sc-bDumWk jbQuod feBYnB">Authorizations:</h5><svg class="sc-cwHptR dSJqIk" version="1.1" viewBox="0 0 24 24" x="0" xmlns="http://www.w3.org/2000/svg" y="0" aria-hidden="true"><polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "></polygon></svg></div><div class="sc-fifgRP gNcumo"><span class="sc-sLsrZ iTheFK">(<span class="sc-kbousE iMnLRS">API Key: <i>GitLab_PersonalAccessToken</i></span><span class="sc-kbousE iMnLRS">OpenID Connect: <i>GitLab_OpenIdConnect</i></span><span class="sc-kbousE iMnLRS">HTTP: <i>basicAuth</i></span>) </span><span class="sc-sLsrZ iTheFK"><span class="sc-kbousE iMnLRS">OAuth2: <i>petstore_auth</i> (<code class="sc-gfoqjT dapMvh">write:pets</code><code class="sc-gfoqjT dapMvh">read:pets</code>) </span></span></div></div><div class="sc-iEXKAA ebCiwb"><h5><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="11" height="11"><path fill="currentColor" d="M18 10V6A6 6 0 0 0 6 6v4H3v14h18V10h-3zM8 6c0-2.206 1.794-4 4-4s4 1.794 4 4v4H8V6zm11 16H5V12h14v10z"></path></svg> OAuth2: petstore_auth</h5><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><p>Get access to data while protecting your account credentials.
OAuth2 is also a safer and more secure way to give you access.</p>
</div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-dkmUuB hFwAIA"><b>Flow type: </b><code>implicit </code></div><div class="sc-dkmUuB hFwAIA"><strong> Authorization URL: </strong><code><a target="_blank" rel="noopener noreferrer" href="http://petstore.swagger.io/api/oauth/dialog">http://petstore.swagger.io/api/oauth/dialog</a></code></div><div><b>Required scopes: </b><code>write:pets</code> <code>read:pets</code> </div><div class="sc-dkmUuB hFwAIA"><b> Scopes: </b></div><div class="sc-iEXKAA blExNw container" style="height: 4em;"><ul><li><code>write:pets</code> - <div class="sc-eeDRCY sc-eBMEME sc-fhzFiK gTGgei iCmQdS hXtrri redoc-markdown"><p>modify pets in your account</p>
</div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-ejfMa-d bdDYxc"><b>Flow type: </b><code>implicit </code></div><div class="sc-ejfMa-d bdDYxc"><strong> Authorization URL: </strong><code><a target="_blank" rel="noopener noreferrer" href="http://petstore.swagger.io/api/oauth/dialog">http://petstore.swagger.io/api/oauth/dialog</a></code></div><div><b>Required scopes: </b><code>write:pets</code> <code>read:pets</code> </div><div class="sc-ejfMa-d bdDYxc"><b> Scopes: </b></div><div class="sc-EgOXT kRIdPi container" style="height: 4em;"><ul><li><code>write:pets</code> - <div class="sc-eeDRCY sc-eBMEME sc-fhzFiK gTGgei iCmQdS hXtrri redoc-markdown"><p>modify pets in your account</p>
</div></li><li><code>read:pets</code> - <div class="sc-eeDRCY sc-eBMEME sc-fhzFiK gTGgei iCmQdS hXtrri redoc-markdown"><p>read your pets</p>
</div></li></ul></div><div class="sc-EgOXT bNSpXO"></div></div></div><div class="sc-ejfMa-d a-DjBE"><h5><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="11" height="11"><path fill="currentColor" d="M18 10V6A6 6 0 0 0 6 6v4H3v14h18V10h-3zM8 6c0-2.206 1.794-4 4-4s4 1.794 4 4v4H8V6zm11 16H5V12h14v10z"></path></svg> API Key: GitLab_PersonalAccessToken</h5><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><p>GitLab Personal Access Token description</p>
</div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-dkmUuB hFwAIA"><b>Header parameter name: </b><code>PRIVATE-TOKEN</code></div></div></div><div class="sc-ejfMa-d a-DjBE"><h5><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="11" height="11"><path fill="currentColor" d="M18 10V6A6 6 0 0 0 6 6v4H3v14h18V10h-3zM8 6c0-2.206 1.794-4 4-4s4 1.794 4 4v4H8V6zm11 16H5V12h14v10z"></path></svg> OpenID Connect: GitLab_OpenIdConnect</h5><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><p>GitLab OpenIdConnect description</p>
</div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-dkmUuB hFwAIA"><b>Connect URL: </b><code><a target="_blank" rel="noopener noreferrer" href="https://gitlab.com/.well-known/openid-configuration">https://gitlab.com/.well-known/openid-configuration</a></code></div></div></div><div class="sc-ejfMa-d a-DjBE"><h5><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="11" height="11"><path fill="currentColor" d="M18 10V6A6 6 0 0 0 6 6v4H3v14h18V10h-3zM8 6c0-2.206 1.794-4 4-4s4 1.794 4 4v4H8V6zm11 16H5V12h14v10z"></path></svg> HTTP: basicAuth</h5><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"></div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-dkmUuB hFwAIA"><b>HTTP Authorization Scheme: </b><code>basic</code></div><div class="sc-dkmUuB hFwAIA"></div></div></div>,"
</div></li></ul></div><div class="sc-eZYNyq dIKkVb"></div></div></div><div class="sc-iEXKAA ebCiwb"><h5><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="11" height="11"><path fill="currentColor" d="M18 10V6A6 6 0 0 0 6 6v4H3v14h18V10h-3zM8 6c0-2.206 1.794-4 4-4s4 1.794 4 4v4H8V6zm11 16H5V12h14v10z"></path></svg> API Key: GitLab_PersonalAccessToken</h5><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><p>GitLab Personal Access Token description</p>
</div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-ejfMa-d bdDYxc"><b>Header parameter name: </b><code>PRIVATE-TOKEN</code></div></div></div><div class="sc-iEXKAA ebCiwb"><h5><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="11" height="11"><path fill="currentColor" d="M18 10V6A6 6 0 0 0 6 6v4H3v14h18V10h-3zM8 6c0-2.206 1.794-4 4-4s4 1.794 4 4v4H8V6zm11 16H5V12h14v10z"></path></svg> OpenID Connect: GitLab_OpenIdConnect</h5><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><p>GitLab OpenIdConnect description</p>
</div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-ejfMa-d bdDYxc"><b>Connect URL: </b><code><a target="_blank" rel="noopener noreferrer" href="https://gitlab.com/.well-known/openid-configuration">https://gitlab.com/.well-known/openid-configuration</a></code></div></div></div><div class="sc-iEXKAA ebCiwb"><h5><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="11" height="11"><path fill="currentColor" d="M18 10V6A6 6 0 0 0 6 6v4H3v14h18V10h-3zM8 6c0-2.206 1.794-4 4-4s4 1.794 4 4v4H8V6zm11 16H5V12h14v10z"></path></svg> HTTP: basicAuth</h5><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"></div><div class="sc-eeDRCY sc-eBMEME gTGgei fMmru"><div class="sc-ejfMa-d bdDYxc"><b>HTTP Authorization Scheme: </b><code>basic</code></div><div class="sc-ejfMa-d bdDYxc"></div></div></div>,"
`;

View File

@ -0,0 +1,24 @@
{
"openapi": "3.0.0",
"info": {
"version": "1.0",
"title": "Test"
},
"components": {
"schemas": {
"Test": {
"type": "array",
"description": "test description",
"items": {
"type": "string",
"description": "test description",
"enum": ["authorize", "do-nothing"],
"x-enumDescriptions": {
"authorize-and-void": "Will create an authorize transaction in the amount/currency of the request, followed by a void",
"do-nothing": "Will do nothing, and return an approved `setup` transaction. This is the default behavior."
}
}
}
}
}
}

View File

@ -142,7 +142,15 @@ describe('Models', () => {
downloadUrls: [{ title: 'Openapi description', url: 'https:test.com/filename.yaml' }],
});
const info = new ApiInfoModel(parser, opts);
expect(info.downloadLink).toEqual('https:test.com/filename.yaml');
expect(info.downloadUrls).toMatchInlineSnapshot(`
[
{
"title": "Openapi description",
"url": "https:test.com/filename.yaml",
},
]
`);
expect(info.downloadFileName).toMatchInlineSnapshot(`"openapi.json"`);
});
test('should correctly populate download link and download file name', () => {
@ -158,15 +166,29 @@ describe('Models', () => {
downloadFileName: 'test.yaml',
});
const info = new ApiInfoModel(parser, opts);
expect(info.downloadLink).toEqual('https:test.com/filename.yaml');
expect(info.downloadFileName).toEqual('test.yaml');
expect(info.downloadUrls).toMatchInlineSnapshot(`
[
{
"title": "Download",
"url": "https:test.com/filename.yaml",
},
]
`);
expect(info.downloadFileName).toMatchInlineSnapshot(`"test.yaml"`);
const opts2 = new RedocNormalizedOptions({
downloadUrls: [{ title: 'test.yaml', url: 'https:test.com/filename.yaml' }],
downloadUrls: [{ title: 'Download file', url: 'https:test.com/filename.yaml' }],
});
const info2 = new ApiInfoModel(parser, opts2);
expect(info2.downloadLink).toEqual('https:test.com/filename.yaml');
expect(info2.downloadFileName).toEqual('test.yaml');
expect(info2.downloadUrls).toMatchInlineSnapshot(`
[
{
"title": "Download file",
"url": "https:test.com/filename.yaml",
},
]
`);
expect(info2.downloadFileName).toMatchInlineSnapshot(`"openapi.json"`);
});
});
});

View File

@ -13,6 +13,17 @@ describe('Models', () => {
describe('Schema', () => {
let parser;
test('parsing nested x-enumDescription', () => {
const spec = require('../fixtures/nestedEnumDescroptionSample.json');
parser = new OpenAPIParser(spec, undefined, opts);
const testSchema = spec.components.schemas.Test;
const schemaModel = new SchemaModel(parser, testSchema, '', opts);
expect(schemaModel['x-enumDescriptions']).toStrictEqual(
testSchema.items['x-enumDescriptions'],
);
});
test('discriminator with one field', () => {
const spec = require('../fixtures/discriminator.json');
parser = new OpenAPIParser(spec, undefined, opts);

View File

@ -34,7 +34,7 @@ export class ApiInfoModel implements OpenAPIInfo {
}
this.downloadUrls = this.getDownloadUrls();
this.downloadFileName = this.options.downloadFileName || 'openapi.json';
this.downloadFileName = this.getDownloadFileName();
}
private getDownloadUrls() {
return (
@ -68,4 +68,11 @@ export class ApiInfoModel implements OpenAPIInfo {
return window.URL.createObjectURL(blob);
}
}
private getDownloadFileName(): string | undefined {
if (!this.parser.specUrl && !this.options.downloadDefinitionUrl) {
return this.options.downloadFileName || 'openapi.json';
}
return this.options.downloadFileName;
}
}

View File

@ -65,6 +65,7 @@ export class SchemaModel {
rawSchema: OpenAPISchema;
schema: MergedOpenAPISchema;
extensions?: Record<string, any>;
'x-enumDescriptions': { [name: string]: string };
const: any;
contentEncoding?: string;
contentMediaType?: string;
@ -122,6 +123,7 @@ export class SchemaModel {
this.type = schema.type || detectType(schema);
this.format = schema.format;
this.enum = schema.enum || [];
this['x-enumDescriptions'] = schema['x-enumDescriptions'];
this.example = schema.example;
this.examples = schema.examples;
this.deprecated = !!schema.deprecated;
@ -221,6 +223,7 @@ export class SchemaModel {
}
if (this.items?.isPrimitive) {
this.enum = this.items.enum;
this['x-enumDescriptions'] = this.items['x-enumDescriptions'];
}
if (isArray(this.type)) {
const filteredType = this.type.filter(item => item !== 'array');

View File

@ -311,6 +311,11 @@ exports[`#loadAndBundleSpec should load And Bundle Spec demo/openapi.yaml 1`] =
"sold",
],
"type": "string",
"x-enumDescriptions": {
"available": "Available status",
"pending": "Pending status",
"sold": "Sold status",
},
},
"tags": {
"description": "Tags attached to the pet",

View File

@ -654,6 +654,7 @@ export function isRedocExtension(key: string): boolean {
'x-codeSamples': true,
'x-displayName': true,
'x-examples': true,
'x-enumDescriptions': true,
'x-ignoredHeaderParameters': true,
'x-logo': true,
'x-nullable': true,