mirror of
https://github.com/Redocly/redoc.git
synced 2025-03-03 17:35:46 +03:00
feat: array size info based on min max Items properties (#1308)
This commit is contained in:
parent
41b8b5d77b
commit
644e96ae45
|
@ -4,6 +4,7 @@ import { Schema, SchemaProps } from './Schema';
|
||||||
|
|
||||||
import { ArrayClosingLabel, ArrayOpenningLabel } from '../../common-elements';
|
import { ArrayClosingLabel, ArrayOpenningLabel } from '../../common-elements';
|
||||||
import styled from '../../styled-components';
|
import styled from '../../styled-components';
|
||||||
|
import {humanizeConstraints} from "../../utils";
|
||||||
|
|
||||||
const PaddedSchema = styled.div`
|
const PaddedSchema = styled.div`
|
||||||
padding-left: ${({ theme }) => theme.spacing.unit * 2}px;
|
padding-left: ${({ theme }) => theme.spacing.unit * 2}px;
|
||||||
|
@ -12,9 +13,16 @@ const PaddedSchema = styled.div`
|
||||||
export class ArraySchema extends React.PureComponent<SchemaProps> {
|
export class ArraySchema extends React.PureComponent<SchemaProps> {
|
||||||
render() {
|
render() {
|
||||||
const itemsSchema = this.props.schema.items!;
|
const itemsSchema = this.props.schema.items!;
|
||||||
|
const itemConstraintSchema = (
|
||||||
|
min: number | undefined = undefined,
|
||||||
|
max: number | undefined = undefined,
|
||||||
|
) => ({ type: 'array', minItems: min, maxItems: max });
|
||||||
|
|
||||||
|
const minMaxItems = humanizeConstraints(itemConstraintSchema(itemsSchema.schema.minItems, itemsSchema.schema.maxItems));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<ArrayOpenningLabel> Array </ArrayOpenningLabel>
|
<ArrayOpenningLabel> Array ({minMaxItems})</ArrayOpenningLabel>
|
||||||
<PaddedSchema>
|
<PaddedSchema>
|
||||||
<Schema {...this.props} schema={itemsSchema} />
|
<Schema {...this.props} schema={itemsSchema} />
|
||||||
</PaddedSchema>
|
</PaddedSchema>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user