@@ -4,95 +4,93 @@ const {
4
4
validate
5
5
} = require ( '../../../../src/plugins/validation/2and3/semantic-validators/info' ) ;
6
6
7
- describe ( 'validation plugin - semantic - error handling for incorrect formatting' , ( ) => {
8
- describe ( 'there should be errors when the defintion is missing neccesrry fields' , function ( ) {
9
- //this is for openapi object
10
- it ( 'should return an error when a parameter does not have info' , ( ) => {
11
- const spec = {
12
- Openapi : '3.0.0'
13
- } ;
7
+ describe ( 'validation plugin - semantic - info' , ( ) => {
8
+ //this is for openapi object
9
+ it ( 'should return an error when a parameter does not have info' , ( ) => {
10
+ const spec = {
11
+ Openapi : '3.0.0'
12
+ } ;
14
13
15
- const res = validate ( { jsSpec : spec } , config ) ;
16
- expect ( res . errors . length ) . toEqual ( 1 ) ;
17
- expect ( res . errors [ 0 ] . path ) . toEqual ( [ 'info' ] ) ;
18
- expect ( res . errors [ 0 ] . message ) . toEqual (
19
- 'Missing info object for api defintion'
20
- ) ;
21
- } ) ;
22
- it ( 'should return an error when a title and version is not a string' , ( ) => {
23
- const spec = {
24
- Openapi : '3.0.0' ,
25
- info : {
26
- title : 32 ,
27
- version : '32'
28
- }
29
- } ;
14
+ const res = validate ( { jsSpec : spec } , config ) ;
15
+ expect ( res . errors . length ) . toEqual ( 1 ) ;
16
+ expect ( res . errors [ 0 ] . path ) . toEqual ( [ 'info' ] ) ;
17
+ expect ( res . errors [ 0 ] . message ) . toEqual (
18
+ 'API definition must have an `info` object'
19
+ ) ;
20
+ } ) ;
21
+ it ( 'should return an error when a info is not defined as a proper object' , ( ) => {
22
+ const spec = {
23
+ Openapi : '3.0.0' ,
24
+ info : 'abc'
25
+ } ;
30
26
31
- const res = validate ( { jsSpec : spec } , config ) ;
32
- expect ( res . errors . length ) . toEqual ( 1 ) ;
33
- expect ( res . errors [ 0 ] . path ) . toEqual ( [ 'info' , 'title '] ) ;
34
- expect ( res . errors [ 0 ] . message ) . toEqual (
35
- ' Info object is missng the title field '
36
- ) ;
37
- } ) ;
38
- it ( 'should return an error when a title and version is not a string' , ( ) => {
39
- const spec = {
40
- Openapi : '3.0.0' ,
41
- info : {
42
- title : '32' ,
43
- version : 32
44
- }
45
- } ;
27
+ const res = validate ( { jsSpec : spec } , config ) ;
28
+ expect ( res . errors . length ) . toEqual ( 1 ) ;
29
+ expect ( res . errors [ 0 ] . path ) . toEqual ( [ 'info' ] ) ;
30
+ expect ( res . errors [ 0 ] . message ) . toEqual (
31
+ 'API definition must have an `info` object '
32
+ ) ;
33
+ } ) ;
34
+ it ( 'should return an error when a title and version is not a string' , ( ) => {
35
+ const spec = {
36
+ Openapi : '3.0.0' ,
37
+ info : {
38
+ title : 32 ,
39
+ version : '32'
40
+ }
41
+ } ;
46
42
47
- const res = validate ( { jsSpec : spec } , config ) ;
48
- expect ( res . errors . length ) . toEqual ( 1 ) ;
49
- expect ( res . errors [ 0 ] . path ) . toEqual ( [ 'info' , 'version' ] ) ;
50
- expect ( res . errors [ 0 ] . message ) . toEqual (
51
- ' Info object is missng the version field'
52
- ) ;
53
- } ) ;
54
- it ( 'should return an error when a title is missing' , ( ) => {
55
- const spec = {
56
- Openapi : '3.0.0' ,
57
- info : {
58
- version : '32'
59
- }
60
- } ;
43
+ const res = validate ( { jsSpec : spec } , config ) ;
44
+ expect ( res . errors . length ) . toEqual ( 1 ) ;
45
+ expect ( res . errors [ 0 ] . path ) . toEqual ( [ 'info' , 'title' ] ) ;
46
+ expect ( res . errors [ 0 ] . message ) . toEqual (
47
+ '`info` object must have a string-type `title` field'
48
+ ) ;
49
+ } ) ;
50
+ it ( 'should return an error when a title and version is not a string' , ( ) => {
51
+ const spec = {
52
+ Openapi : '3.0.0' ,
53
+ info : {
54
+ title : '32' ,
55
+ version : 32
56
+ }
57
+ } ;
61
58
62
- const res = validate ( { jsSpec : spec } , config ) ;
63
- expect ( res . errors . length ) . toEqual ( 1 ) ;
64
- expect ( res . errors [ 0 ] . path ) . toEqual ( [ 'info' , 'title ' ] ) ;
65
- expect ( res . errors [ 0 ] . message ) . toEqual (
66
- ' Info object is missng the title field'
67
- ) ;
68
- } ) ;
69
- it ( 'should return an error when a version is missing' , ( ) => {
70
- const spec = {
71
- Openapi : '3.0.0' ,
72
- info : {
73
- title : '32'
74
- }
75
- } ;
59
+ const res = validate ( { jsSpec : spec } , config ) ;
60
+ expect ( res . errors . length ) . toEqual ( 1 ) ;
61
+ expect ( res . errors [ 0 ] . path ) . toEqual ( [ 'info' , 'version ' ] ) ;
62
+ expect ( res . errors [ 0 ] . message ) . toEqual (
63
+ '`info` object must have a string-type `version` field'
64
+ ) ;
65
+ } ) ;
66
+ it ( 'should return an error when a title is missing' , ( ) => {
67
+ const spec = {
68
+ Openapi : '3.0.0' ,
69
+ info : {
70
+ version : '32'
71
+ }
72
+ } ;
76
73
77
- const res = validate ( { jsSpec : spec } , config ) ;
78
- expect ( res . errors . length ) . toEqual ( 1 ) ;
79
- expect ( res . errors [ 0 ] . path ) . toEqual ( [ 'info' , 'version' ] ) ;
80
- expect ( res . errors [ 0 ] . message ) . toEqual (
81
- ' Info object is missng the version field'
82
- ) ;
83
- } ) ;
84
- it ( 'should return an error when a info is not defined as a proper object' , ( ) => {
85
- const spec = {
86
- Openapi : '3.0.0' ,
87
- info : 'abc'
88
- } ;
74
+ const res = validate ( { jsSpec : spec } , config ) ;
75
+ expect ( res . errors . length ) . toEqual ( 1 ) ;
76
+ expect ( res . errors [ 0 ] . path ) . toEqual ( [ 'info' , 'title' ] ) ;
77
+ expect ( res . errors [ 0 ] . message ) . toEqual (
78
+ '`info` object must have a string-type `title` field'
79
+ ) ;
80
+ } ) ;
81
+ it ( 'should return an error when a version is missing' , ( ) => {
82
+ const spec = {
83
+ Openapi : '3.0.0' ,
84
+ info : {
85
+ title : '32'
86
+ }
87
+ } ;
89
88
90
- const res = validate ( { jsSpec : spec } , config ) ;
91
- expect ( res . errors . length ) . toEqual ( 1 ) ;
92
- expect ( res . errors [ 0 ] . path ) . toEqual ( [ 'info' ] ) ;
93
- expect ( res . errors [ 0 ] . message ) . toEqual (
94
- 'Info is an obect and must have properties'
95
- ) ;
96
- } ) ;
89
+ const res = validate ( { jsSpec : spec } , config ) ;
90
+ expect ( res . errors . length ) . toEqual ( 1 ) ;
91
+ expect ( res . errors [ 0 ] . path ) . toEqual ( [ 'info' , 'version' ] ) ;
92
+ expect ( res . errors [ 0 ] . message ) . toEqual (
93
+ '`info` object must have a string-type `version` field'
94
+ ) ;
97
95
} ) ;
98
96
} ) ;
0 commit comments