mirror of
				https://github.com/Redocly/redoc.git
				synced 2025-11-04 01:37:32 +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 { 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>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,7 +80,9 @@ export function BodyContent(props: {
 | 
			
		|||
        return (
 | 
			
		||||
          <>
 | 
			
		||||
            {description !== undefined && <Markdown source={description} />}
 | 
			
		||||
            <ConstraintsView constraints={schema?.constraints || []} />
 | 
			
		||||
            {schema?.type === 'object' && (
 | 
			
		||||
              <ConstraintsView constraints={schema?.constraints || []} />
 | 
			
		||||
            )}
 | 
			
		||||
            <Schema
 | 
			
		||||
              skipReadOnly={isRequestType}
 | 
			
		||||
              skipWriteOnly={!isRequestType}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,7 +24,9 @@ export class ResponseDetails extends React.PureComponent<{ response: ResponseMod
 | 
			
		|||
          {({ schema }) => {
 | 
			
		||||
            return (
 | 
			
		||||
              <>
 | 
			
		||||
                <ConstraintsView constraints={schema?.constraints || []} />
 | 
			
		||||
                {schema?.type === 'object' && (
 | 
			
		||||
                  <ConstraintsView constraints={schema?.constraints || []} />
 | 
			
		||||
                )}
 | 
			
		||||
                <Schema skipWriteOnly={true} key="schema" schema={schema} />
 | 
			
		||||
              </>
 | 
			
		||||
            );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user