@@ -43,12 +43,33 @@ def convert(schema, options=None):
43
43
if options ['cloneSchema' ]:
44
44
schema = json .loads (json .dumps (schema ))
45
45
46
- schema = convertSchema (schema , options )
46
+ schema = convertDoc (schema , options )
47
47
schema ['$schema' ] = 'http://json-schema.org/draft-04/schema#'
48
48
49
49
return schema
50
50
51
51
52
+ def convertDoc (schema , options ):
53
+ components_schemas = schema .get ('components' , {}).get ('schemas' )
54
+ if components_schemas :
55
+ for name , struct in list (components_schemas .items ()):
56
+ components_schemas [name ] = convertSchema (struct , options )
57
+
58
+ paths = schema .get ('paths' )
59
+ if paths :
60
+ for path , path_struct in paths .items ():
61
+ for operation , op_struct in path_struct .items ():
62
+ for param in op_struct .get ('parameters' , []):
63
+ param_schema = param .get ('schema' )
64
+ if param_schema :
65
+ param ['schema' ] = convertSchema (
66
+ param_schema , options )
67
+
68
+ # TODO requestBody & responses
69
+
70
+ return convertSchema (schema , options )
71
+
72
+
52
73
def convertSchema (schema , options ):
53
74
structs = options ['_structs' ]
54
75
notSupported = options ['_notSupported' ]
0 commit comments