@@ -5,31 +5,34 @@ module.exports = convertFromParameter;
5
5
6
6
// Convert from OpenAPI 3.0 `ParameterObject` to JSON schema v4
7
7
function convertFromParameter ( parameter , options ) {
8
- if ( parameter . schema !== undefined ) {
9
- return convertParameterSchema ( parameter , parameter . schema , options ) ;
10
- } else if ( parameter . content !== undefined ) {
11
- return convertFromContents ( parameter , options ) ;
12
- } else {
13
- throw new InvalidInputError ( 'OpenAPI parameter must have either a \'schema\' or a \'content\' property' ) ;
14
- }
8
+ if ( parameter . schema !== undefined ) {
9
+ return convertParameterSchema ( parameter , parameter . schema , options ) ;
10
+ } else if ( parameter . content !== undefined ) {
11
+ return convertFromContents ( parameter , options ) ;
12
+ } else {
13
+ if ( options . strictMode ) {
14
+ throw new InvalidInputError ( 'OpenAPI parameter must have either a \'schema\' or a \'content\' property' ) ;
15
+ }
16
+ return convertParameterSchema ( parameter , { } , options ) ;
17
+ }
15
18
}
16
19
17
20
function convertFromContents ( parameter , options ) {
18
- var schemas = { } ;
21
+ var schemas = { } ;
19
22
20
- for ( var mime in parameter . content ) {
21
- schemas [ mime ] = convertParameterSchema ( parameter , parameter . content [ mime ] . schema , options ) ;
22
- }
23
+ for ( var mime in parameter . content ) {
24
+ schemas [ mime ] = convertParameterSchema ( parameter , parameter . content [ mime ] . schema , options ) ;
25
+ }
23
26
24
- return schemas ;
27
+ return schemas ;
25
28
}
26
29
27
30
function convertParameterSchema ( parameter , schema , options ) {
28
- var jsonSchema = convertFromSchema ( schema || { } , options ) ;
31
+ var jsonSchema = convertFromSchema ( schema || { } , options ) ;
29
32
30
- if ( parameter . description ) {
31
- jsonSchema . description = parameter . description ;
32
- }
33
+ if ( parameter . description ) {
34
+ jsonSchema . description = parameter . description ;
35
+ }
33
36
34
- return jsonSchema ;
37
+ return jsonSchema ;
35
38
}
0 commit comments