fix: constraints label details

This commit is contained in:
Alex Varchuk 2022-05-20 10:44:02 +03:00
parent 77104d6c0d
commit eb0917d002
3 changed files with 18 additions and 3 deletions

View File

@ -4,9 +4,20 @@ import { ConstraintsView } from './FieldContstraints';
import { Pattern } from './Pattern';
import { SchemaModel } from '../../services';
import styled from '../../styled-components';
import { OptionsContext } from '../OptionsProvider';
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 (
<Wrapper>

View File

@ -80,7 +80,9 @@ export function BodyContent(props: {
return (
<>
{description !== undefined && <Markdown source={description} />}
{schema?.type === 'object' && (
<ConstraintsView constraints={schema?.constraints || []} />
)}
<Schema
skipReadOnly={isRequestType}
skipWriteOnly={!isRequestType}

View File

@ -24,7 +24,9 @@ export class ResponseDetails extends React.PureComponent<{ response: ResponseMod
{({ schema }) => {
return (
<>
{schema?.type === 'object' && (
<ConstraintsView constraints={schema?.constraints || []} />
)}
<Schema skipWriteOnly={true} key="schema" schema={schema} />
</>
);