-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show minProperties maxProperties (#2015)
- Loading branch information
1 parent
0aafee1
commit 82712c5
Showing
9 changed files
with
128 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* tslint:disable:no-implicit-dependencies */ | ||
|
||
import { shallow } from 'enzyme'; | ||
import * as React from 'react'; | ||
|
||
import { Schema } from '../'; | ||
import { OpenAPIParser, SchemaModel } from '../../services'; | ||
import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions'; | ||
import { withTheme } from '../testProviders'; | ||
|
||
const options = new RedocNormalizedOptions({}); | ||
describe('Components', () => { | ||
describe('SchemaView', () => { | ||
const parser = new OpenAPIParser( | ||
{ openapi: '3.0', info: { title: 'test', version: '0' }, paths: {} }, | ||
undefined, | ||
options, | ||
); | ||
|
||
describe('Show minProperties/maxProperties constraints', () => { | ||
const schema = new SchemaModel( | ||
parser, | ||
{ | ||
properties: { | ||
name: { | ||
type: 'object', | ||
minProperties: 1, | ||
properties: { | ||
address: { | ||
type: 'string', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
'', | ||
options, | ||
); | ||
const component = shallow(withTheme(<Schema schema={schema} />)); | ||
expect(component.html().includes('non-empty')).toBe(true); | ||
}); | ||
|
||
describe('Show range minProperties/maxProperties constraints', () => { | ||
const schema = new SchemaModel( | ||
parser, | ||
{ | ||
properties: { | ||
name: { | ||
type: 'object', | ||
minProperties: 2, | ||
maxProperties: 10, | ||
additionalProperties: { | ||
type: 'string', | ||
}, | ||
}, | ||
}, | ||
}, | ||
'', | ||
options, | ||
); | ||
it('should includes [ 2 .. 10 ] properties', () => { | ||
const component = shallow(withTheme(<Schema schema={schema} />)); | ||
expect(component.html().includes('[ 2 .. 10 ] properties')).toBe(true); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -966,6 +966,7 @@ try { | |
"format": "int32", | ||
"type": "integer", | ||
}, | ||
"minProperties": 2, | ||
"type": "object", | ||
}, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters