88
99
1010def convert_to_schema_or_json (schema , spec : APISpec ):
11- """
12- Ensure that a given schema is either a real Marshmallow schema,
11+ """Ensure that a given schema is either a real Marshmallow schema,
1312 or is a dictionary describing the schema inline.
14-
13+
1514 Marshmallow schemas are left as they are so that the APISpec module
1615 can add them to the "schemas" list in our APISpec documentation.
16+
17+ :param schema:
18+ :param spec: APISpec:
19+
1720 """
1821 # Don't process Nones
1922 if not schema :
@@ -35,9 +38,12 @@ def convert_to_schema_or_json(schema, spec: APISpec):
3538
3639
3740def map_to_properties (schema , spec : APISpec ):
38- """
39- Recursively convert any dictionary-like map of Marshmallow fields
41+ """Recursively convert any dictionary-like map of Marshmallow fields
4042 into a dictionary describing it's JSON schema
43+
44+ :param schema:
45+ :param spec: APISpec:
46+
4147 """
4248
4349 d = {}
@@ -53,7 +59,12 @@ def map_to_properties(schema, spec: APISpec):
5359
5460
5561def field_to_property (field , spec : APISpec ):
56- """Convert a single Marshmallow field into a JSON schema of that field"""
62+ """Convert a single Marshmallow field into a JSON schema of that field
63+
64+ :param field:
65+ :param spec: APISpec:
66+
67+ """
5768 marshmallow_plugin = next (
5869 plugin for plugin in spec .plugins if isinstance (plugin , MarshmallowPlugin )
5970 )
@@ -68,11 +79,14 @@ def field_to_property(field, spec: APISpec):
6879
6980
7081def schema_to_json (schema , spec : APISpec ):
71- """
72- Convert any Marshmallow schema stright to a fully expanded JSON schema.
82+ """Convert any Marshmallow schema stright to a fully expanded JSON schema.
7383 This should not be used when generating APISpec documentation,
7484 otherwise schemas wont be listed in the "schemas" list.
7585 This is used, for example, in the Thing Description.
86+
87+ :param schema:
88+ :param spec: APISpec:
89+
7690 """
7791
7892 if isinstance (schema , Schema ):
@@ -89,10 +103,13 @@ def schema_to_json(schema, spec: APISpec):
89103
90104
91105def recursive_expand_refs (schema_dict , spec : APISpec ):
92- """
93- Traverse `schema_dict` expanding out all schema $ref values where possible.
94-
106+ """Traverse `schema_dict` expanding out all schema $ref values where possible.
107+
95108 Used when generating Thing Descriptions, so each attribute contains full schemas.
109+
110+ :param schema_dict:
111+ :param spec: APISpec:
112+
96113 """
97114 if isinstance (schema_dict , Mapping ):
98115 if "$ref" in schema_dict :
@@ -106,10 +123,13 @@ def recursive_expand_refs(schema_dict, spec: APISpec):
106123
107124
108125def expand_refs (schema_dict , spec : APISpec ):
109- """
110- Expand out all schema $ref values where possible.
111-
126+ """Expand out all schema $ref values where possible.
127+
112128 Uses the $ref value to look up a particular schema in spec schemas
129+
130+ :param schema_dict:
131+ :param spec: APISpec:
132+
113133 """
114134 if "$ref" not in schema_dict :
115135 return schema_dict
0 commit comments