mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 00:26:34 +03:00
fix: nested patternProperties (#2073)
This commit is contained in:
parent
4fc6aa0859
commit
9920991080
|
@ -25,6 +25,26 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"nestedObjectProp": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
".*": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"nestedArrayProp": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"patternProperties": {
|
||||
".*": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,11 +107,22 @@ describe('Models', () => {
|
|||
const spec = require('../fixtures/3.1/patternProperties.json');
|
||||
parser = new OpenAPIParser(spec, undefined, opts);
|
||||
const schema = new SchemaModel(parser, spec.components.schemas.Patterns, '', opts);
|
||||
expect(schema.fields).toHaveLength(2);
|
||||
expect(schema.fields![0].kind).toEqual('patternProperties');
|
||||
expect(schema.fields![0].schema.type).toEqual('string');
|
||||
expect(schema.fields![1].kind).toEqual('patternProperties');
|
||||
expect(schema.fields![1].schema.type).toEqual('object');
|
||||
|
||||
expect(schema.fields).toHaveLength(4);
|
||||
expect(schema.fields![0].kind).toEqual('field');
|
||||
expect(schema.fields![0].name).toEqual('nestedObjectProp');
|
||||
expect(schema.fields![0].schema.type).toEqual('object');
|
||||
expect(schema.fields![0].schema.fields![0].kind).toEqual('patternProperties');
|
||||
|
||||
expect(schema.fields).toHaveLength(4);
|
||||
expect(schema.fields![1].kind).toEqual('field');
|
||||
expect(schema.fields![1].name).toEqual('nestedArrayProp');
|
||||
expect(schema.fields![1].schema.items!.fields![0].kind).toEqual('patternProperties');
|
||||
|
||||
expect(schema.fields![2].kind).toEqual('patternProperties');
|
||||
expect(schema.fields![2].schema.type).toEqual('string');
|
||||
expect(schema.fields![3].kind).toEqual('patternProperties');
|
||||
expect(schema.fields![3].schema.type).toEqual('object');
|
||||
});
|
||||
|
||||
describe('type array', () => {
|
||||
|
|
|
@ -136,7 +136,9 @@ export function isPrimitiveType(
|
|||
isPrimitive =
|
||||
schema.properties !== undefined
|
||||
? Object.keys(schema.properties).length === 0
|
||||
: schema.additionalProperties === undefined && schema.unevaluatedProperties === undefined;
|
||||
: schema.additionalProperties === undefined &&
|
||||
schema.unevaluatedProperties === undefined &&
|
||||
schema.patternProperties === undefined;
|
||||
}
|
||||
|
||||
if (isArray(schema.items) || isArray(schema.prefixItems)) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user