mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 00:26:34 +03:00
This commit is contained in:
parent
43451ba4cd
commit
3b8d6441bd
|
@ -533,6 +533,20 @@ paths:
|
||||||
subscriptionId:
|
subscriptionId:
|
||||||
type: string
|
type: string
|
||||||
example: AAA-123-BBB-456
|
example: AAA-123-BBB-456
|
||||||
|
'200':
|
||||||
|
description: Successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
maxItems: 999
|
||||||
|
minItems: 0
|
||||||
|
items:
|
||||||
|
type: array
|
||||||
|
maxItems: 777
|
||||||
|
minItems: 111
|
||||||
|
items:
|
||||||
|
type: number
|
||||||
callbacks:
|
callbacks:
|
||||||
orderInProgress:
|
orderInProgress:
|
||||||
'{$request.body#/callbackUrl}?event={$request.body#/eventName}':
|
'{$request.body#/callbackUrl}?event={$request.body#/eventName}':
|
||||||
|
|
|
@ -377,7 +377,9 @@ paths:
|
||||||
application/xml:
|
application/xml:
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
|
maxItems: 999
|
||||||
items:
|
items:
|
||||||
|
maxItems: 111
|
||||||
$ref: '#/components/schemas/Pet'
|
$ref: '#/components/schemas/Pet'
|
||||||
'400':
|
'400':
|
||||||
description: Invalid tag value
|
description: Invalid tag value
|
||||||
|
|
|
@ -13,15 +13,12 @@ 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 schema = this.props.schema;
|
const schema = this.props.schema;
|
||||||
|
const itemsSchema = schema.items;
|
||||||
|
|
||||||
const itemConstraintSchema = (
|
const minMaxItems = schema.minItems === undefined && schema.maxItems === undefined ?
|
||||||
min: number | undefined = undefined,
|
'' :
|
||||||
max: number | undefined = undefined,
|
`(${humanizeConstraints(schema)})`;
|
||||||
) => ({ type: 'array', minItems: min, maxItems: max });
|
|
||||||
|
|
||||||
const minMaxItems = humanizeConstraints(itemConstraintSchema(itemsSchema?.schema?.minItems, itemsSchema?.schema?.maxItems));
|
|
||||||
|
|
||||||
if (schema.displayType && !itemsSchema && !minMaxItems.length) {
|
if (schema.displayType && !itemsSchema && !minMaxItems.length) {
|
||||||
return (<div>
|
return (<div>
|
||||||
|
@ -31,7 +28,7 @@ export class ArraySchema extends React.PureComponent<SchemaProps> {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<ArrayOpenningLabel> Array ({minMaxItems})</ArrayOpenningLabel>
|
<ArrayOpenningLabel> Array {minMaxItems}</ArrayOpenningLabel>
|
||||||
<PaddedSchema>
|
<PaddedSchema>
|
||||||
<Schema {...this.props} schema={itemsSchema} />
|
<Schema {...this.props} schema={itemsSchema} />
|
||||||
</PaddedSchema>
|
</PaddedSchema>
|
||||||
|
|
|
@ -33,6 +33,8 @@ exports[`Components SchemaView discriminator should correctly render discriminat
|
||||||
"format": undefined,
|
"format": undefined,
|
||||||
"isCircular": undefined,
|
"isCircular": undefined,
|
||||||
"isPrimitive": true,
|
"isPrimitive": true,
|
||||||
|
"maxItems": undefined,
|
||||||
|
"minItems": undefined,
|
||||||
"options": "<<<filtered>>>",
|
"options": "<<<filtered>>>",
|
||||||
"pattern": undefined,
|
"pattern": undefined,
|
||||||
"pointer": "#/components/schemas/Dog/properties/packSize",
|
"pointer": "#/components/schemas/Dog/properties/packSize",
|
||||||
|
@ -86,6 +88,8 @@ exports[`Components SchemaView discriminator should correctly render discriminat
|
||||||
"format": undefined,
|
"format": undefined,
|
||||||
"isCircular": undefined,
|
"isCircular": undefined,
|
||||||
"isPrimitive": true,
|
"isPrimitive": true,
|
||||||
|
"maxItems": undefined,
|
||||||
|
"minItems": undefined,
|
||||||
"options": "<<<filtered>>>",
|
"options": "<<<filtered>>>",
|
||||||
"pattern": undefined,
|
"pattern": undefined,
|
||||||
"pointer": "#/components/schemas/Dog/properties/type",
|
"pointer": "#/components/schemas/Dog/properties/type",
|
||||||
|
|
|
@ -63,6 +63,8 @@ export class SchemaModel {
|
||||||
const: any;
|
const: any;
|
||||||
contentEncoding?: string;
|
contentEncoding?: string;
|
||||||
contentMediaType?: string;
|
contentMediaType?: string;
|
||||||
|
minItems?: number;
|
||||||
|
maxItems?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param isChild if schema discriminator Child
|
* @param isChild if schema discriminator Child
|
||||||
|
@ -128,6 +130,8 @@ export class SchemaModel {
|
||||||
this.const = schema.const || '';
|
this.const = schema.const || '';
|
||||||
this.contentEncoding = schema.contentEncoding;
|
this.contentEncoding = schema.contentEncoding;
|
||||||
this.contentMediaType = schema.contentMediaType;
|
this.contentMediaType = schema.contentMediaType;
|
||||||
|
this.minItems = schema.minItems;
|
||||||
|
this.maxItems = schema.maxItems;
|
||||||
|
|
||||||
if (!!schema.nullable || schema['x-nullable']) {
|
if (!!schema.nullable || schema['x-nullable']) {
|
||||||
if (Array.isArray(this.type) && !this.type.some((value) => value === null || value === 'null')) {
|
if (Array.isArray(this.type) && !this.type.some((value) => value === null || value === 'null')) {
|
||||||
|
|
|
@ -729,7 +729,9 @@ try {
|
||||||
"schema": Object {
|
"schema": Object {
|
||||||
"items": Object {
|
"items": Object {
|
||||||
"$ref": "#/components/schemas/Pet",
|
"$ref": "#/components/schemas/Pet",
|
||||||
|
"maxItems": 111,
|
||||||
},
|
},
|
||||||
|
"maxItems": 999,
|
||||||
"type": "array",
|
"type": "array",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -3245,6 +3247,26 @@ culpa qui officia deserunt mollit anim id est laborum.
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"responses": Object {
|
"responses": Object {
|
||||||
|
"200": Object {
|
||||||
|
"content": Object {
|
||||||
|
"application/json": Object {
|
||||||
|
"schema": Object {
|
||||||
|
"items": Object {
|
||||||
|
"items": Object {
|
||||||
|
"type": "number",
|
||||||
|
},
|
||||||
|
"maxItems": 777,
|
||||||
|
"minItems": 111,
|
||||||
|
"type": "array",
|
||||||
|
},
|
||||||
|
"maxItems": 999,
|
||||||
|
"minItems": 0,
|
||||||
|
"type": "array",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"description": "Successful operation",
|
||||||
|
},
|
||||||
"201": Object {
|
"201": Object {
|
||||||
"content": Object {
|
"content": Object {
|
||||||
"application/json": Object {
|
"application/json": Object {
|
||||||
|
|
|
@ -412,10 +412,10 @@ describe('Utils', () => {
|
||||||
|
|
||||||
describe('openapi humanizeConstraints', () => {
|
describe('openapi humanizeConstraints', () => {
|
||||||
const itemConstraintSchema = (
|
const itemConstraintSchema = (
|
||||||
min: number | undefined = undefined,
|
min?: number,
|
||||||
max: number | undefined = undefined,
|
max?: number,
|
||||||
multipleOf: number | undefined = undefined,
|
multipleOf?: number,
|
||||||
uniqueItems?: boolean,
|
uniqueItems?: boolean
|
||||||
) => ({ type: 'array', minItems: min, maxItems: max, multipleOf, uniqueItems });
|
) => ({ type: 'array', minItems: min, maxItems: max, multipleOf, uniqueItems });
|
||||||
|
|
||||||
it('should not have a humanized constraint without schema constraints', () => {
|
it('should not have a humanized constraint without schema constraints', () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user