@@ -5,34 +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
- if ( options . strictMode ) {
14
- throw new InvalidInputError ( 'OpenAPI parameter must have either a \'schema\' or a \'content\' property' ) ;
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
15
}
16
16
return convertParameterSchema ( parameter , { } , options ) ;
17
- }
17
+ }
18
18
}
19
19
20
20
function convertFromContents ( parameter , options ) {
21
- var schemas = { } ;
21
+ var schemas = { } ;
22
22
23
- for ( var mime in parameter . content ) {
24
- schemas [ mime ] = convertParameterSchema ( parameter , parameter . content [ mime ] . schema , options ) ;
25
- }
23
+ for ( var mime in parameter . content ) {
24
+ schemas [ mime ] = convertParameterSchema ( parameter , parameter . content [ mime ] . schema , options ) ;
25
+ }
26
26
27
- return schemas ;
27
+ return schemas ;
28
28
}
29
29
30
30
function convertParameterSchema ( parameter , schema , options ) {
31
- var jsonSchema = convertFromSchema ( schema || { } , options ) ;
31
+ var jsonSchema = convertFromSchema ( schema || { } , options ) ;
32
32
33
- if ( parameter . description ) {
34
- jsonSchema . description = parameter . description ;
35
- }
33
+ if ( parameter . description ) {
34
+ jsonSchema . description = parameter . description ;
35
+ }
36
36
37
- return jsonSchema ;
37
+ return jsonSchema ;
38
38
}
0 commit comments