mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 08:36:33 +03:00
fix: constraints label details
This commit is contained in:
parent
77104d6c0d
commit
eb0917d002
|
@ -4,9 +4,20 @@ import { ConstraintsView } from './FieldContstraints';
|
||||||
import { Pattern } from './Pattern';
|
import { Pattern } from './Pattern';
|
||||||
import { SchemaModel } from '../../services';
|
import { SchemaModel } from '../../services';
|
||||||
import styled from '../../styled-components';
|
import styled from '../../styled-components';
|
||||||
|
import { OptionsContext } from '../OptionsProvider';
|
||||||
|
|
||||||
export function ArrayItemDetails({ schema }: { schema: SchemaModel }) {
|
export function ArrayItemDetails({ schema }: { schema: SchemaModel }) {
|
||||||
if (!schema || (schema.type === 'string' && !schema.constraints.length)) return null;
|
const { hideSchemaPattern } = React.useContext(OptionsContext);
|
||||||
|
if (
|
||||||
|
!schema ||
|
||||||
|
(schema.type === 'string' && !schema.constraints.length) ||
|
||||||
|
((!schema?.pattern || hideSchemaPattern) &&
|
||||||
|
!schema.items &&
|
||||||
|
!schema.displayFormat &&
|
||||||
|
!schema.constraints.length)
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
|
|
|
@ -80,7 +80,9 @@ export function BodyContent(props: {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{description !== undefined && <Markdown source={description} />}
|
{description !== undefined && <Markdown source={description} />}
|
||||||
<ConstraintsView constraints={schema?.constraints || []} />
|
{schema?.type === 'object' && (
|
||||||
|
<ConstraintsView constraints={schema?.constraints || []} />
|
||||||
|
)}
|
||||||
<Schema
|
<Schema
|
||||||
skipReadOnly={isRequestType}
|
skipReadOnly={isRequestType}
|
||||||
skipWriteOnly={!isRequestType}
|
skipWriteOnly={!isRequestType}
|
||||||
|
|
|
@ -24,7 +24,9 @@ export class ResponseDetails extends React.PureComponent<{ response: ResponseMod
|
||||||
{({ schema }) => {
|
{({ schema }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ConstraintsView constraints={schema?.constraints || []} />
|
{schema?.type === 'object' && (
|
||||||
|
<ConstraintsView constraints={schema?.constraints || []} />
|
||||||
|
)}
|
||||||
<Schema skipWriteOnly={true} key="schema" schema={schema} />
|
<Schema skipWriteOnly={true} key="schema" schema={schema} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user