This repository was archived by the owner on Nov 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
packages/openapi2-parser/test Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -220,5 +220,58 @@ describe('bodyFromSchema', () => {
220220 expect ( body ) . to . deep . equal ( { name : 'doe' } ) ;
221221 } ) ;
222222 } ) ;
223+
224+ describe ( 'allOf w/length 1' , ( ) => {
225+ it ( 'can generate an object' , ( ) => {
226+ const schema = {
227+ allOf : [
228+ {
229+ type : 'object' ,
230+ examples : [ { name : 'doe' } ] ,
231+ } ,
232+ ] ,
233+ } ;
234+
235+ const body = generate ( schema ) ;
236+
237+ expect ( body ) . to . deep . equal ( { name : 'doe' } ) ;
238+ } ) ;
239+
240+ it ( 'can generate an array' , ( ) => {
241+ const schema = {
242+ allOf : [
243+ {
244+ type : 'array' ,
245+ items : {
246+ type : 'string' ,
247+ } ,
248+ examples : [ [ 'doe' ] ] ,
249+ } ,
250+ ] ,
251+ } ;
252+
253+ const body = generate ( schema ) ;
254+
255+ expect ( body ) . to . deep . equal ( [ 'doe' ] ) ;
256+ } ) ;
257+
258+ it ( 'can generate an array with items' , ( ) => {
259+ const schema = {
260+ allOf : [
261+ {
262+ type : 'array' ,
263+ items : {
264+ type : 'string' ,
265+ examples : [ 'doe' ] ,
266+ } ,
267+ } ,
268+ ] ,
269+ } ;
270+
271+ const body = generate ( schema ) ;
272+
273+ expect ( body ) . to . deep . equal ( [ 'doe' ] ) ;
274+ } ) ;
275+ } ) ;
223276 } ) ;
224277} ) ;
You can’t perform that action at this time.
0 commit comments