Skip to content

Commit 126fa9c

Browse files
pre-commit-ci[bot]lafrech
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 74608ad commit 126fa9c

File tree

2 files changed

+49
-49
lines changed

2 files changed

+49
-49
lines changed

src/apispec/ext/marshmallow/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class UserSchema(Schema):
5252
created = fields.DateTime(
5353
dump_only=True,
5454
dump_default=dt.datetime.utcnow,
55-
metadata={"default": "The current datetime"}
55+
metadata={"default": "The current datetime"},
5656
)
5757
5858
@@ -108,6 +108,7 @@ class MarshmallowPlugin(BasePlugin):
108108
109109
from apispec.ext.marshmallow.common import resolve_schema_cls
110110
111+
111112
def schema_name_resolver(schema):
112113
schema_cls = resolve_schema_cls(schema)
113114
return schema_cls.__name__

src/apispec/ext/marshmallow/schema_resolver.py

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,28 @@ def resolve_callback(self, callbacks):
4242
4343
Example: ::
4444
45-
#Input
45+
# Input
4646
{
4747
"userEvent": {
4848
"https://my.example/user-callback": {
4949
"post": {
5050
"requestBody": {
51-
"content": {
52-
"application/json": {
53-
"schema": UserSchema
54-
}
55-
}
51+
"content": {"application/json": {"schema": UserSchema}}
5652
}
5753
},
5854
}
5955
}
6056
}
6157
62-
#Output
58+
# Output
6359
{
6460
"userEvent": {
6561
"https://my.example/user-callback": {
6662
"post": {
6763
"requestBody": {
6864
"content": {
6965
"application/json": {
70-
"schema": {
71-
"$ref": "#/components/schemas/User"
72-
}
66+
"schema": {"$ref": "#/components/schemas/User"}
7367
}
7468
}
7569
}
@@ -97,19 +91,28 @@ def resolve_parameters(self, parameters):
9791
9892
Example: ::
9993
100-
#Input
94+
# Input
10195
class UserSchema(Schema):
10296
name = fields.String()
10397
id = fields.Int()
10498
105-
[
106-
{"in": "query", "schema": "UserSchema"}
107-
]
10899
109-
#Output
100+
[{"in": "query", "schema": "UserSchema"}]
101+
102+
# Output
110103
[
111-
{"in": "query", "name": "id", "required": False, "schema": {"type": "integer"}},
112-
{"in": "query", "name": "name", "required": False, "schema": {"type": "string"}}
104+
{
105+
"in": "query",
106+
"name": "id",
107+
"required": False,
108+
"schema": {"type": "integer"},
109+
},
110+
{
111+
"in": "query",
112+
"name": "name",
113+
"required": False,
114+
"schema": {"type": "string"},
115+
},
113116
]
114117
115118
If the Parameter Object contains a `content` key a single Parameter
@@ -118,19 +121,23 @@ class UserSchema(Schema):
118121
119122
Example: ::
120123
121-
#Input
122-
[{"in": "query", "name": "pet", "content":{"application/json": {"schema": "PetSchema"}} }]
124+
# Input
125+
[
126+
{
127+
"in": "query",
128+
"name": "pet",
129+
"content": {"application/json": {"schema": "PetSchema"}},
130+
}
131+
]
123132
124-
#Output
133+
# Output
125134
[
126135
{
127136
"in": "query",
128137
"name": "pet",
129138
"content": {
130-
"application/json": {
131-
"schema": {"$ref": "#/components/schemas/Pet"}
132-
}
133-
}
139+
"application/json": {"schema": {"$ref": "#/components/schemas/Pet"}}
140+
},
134141
}
135142
]
136143
@@ -160,17 +167,17 @@ def resolve_response(self, response):
160167
161168
Example: ::
162169
163-
#Input
170+
# Input
164171
{
165172
"content": {"application/json": {"schema": "PetSchema"}},
166173
"description": "successful operation",
167174
"headers": {"PetHeader": {"schema": "PetHeaderSchema"}},
168175
}
169176
170-
#Output
177+
# Output
171178
{
172179
"content": {
173-
"application/json":{"schema": {"$ref": "#/components/schemas/Pet"}}
180+
"application/json": {"schema": {"$ref": "#/components/schemas/Pet"}}
174181
},
175182
"description": "successful operation",
176183
"headers": {
@@ -192,26 +199,18 @@ def resolve_schema(self, data):
192199
193200
OpenAPIv3 Components: ::
194201
195-
#Input
202+
# Input
196203
{
197204
"description": "user to add to the system",
198-
"content": {
199-
"application/json": {
200-
"schema": "UserSchema"
201-
}
202-
}
205+
"content": {"application/json": {"schema": "UserSchema"}},
203206
}
204207
205-
#Output
208+
# Output
206209
{
207210
"description": "user to add to the system",
208211
"content": {
209-
"application/json": {
210-
"schema": {
211-
"$ref": "#/components/schemas/User"
212-
}
213-
}
214-
}
212+
"application/json": {"schema": {"$ref": "#/components/schemas/User"}}
213+
},
215214
}
216215
217216
:param dict|str data: either a parameter or response dictionary that may
@@ -241,10 +240,10 @@ def resolve_schema_dict(self, schema):
241240
242241
Example: ::
243242
244-
#Input
243+
# Input
245244
"PetSchema"
246245
247-
#Output
246+
# Output
248247
{"$ref": "#/components/schemas/Pet"}
249248
250249
If the input is a dictionary representation of an OpenAPI Schema Object
@@ -255,22 +254,22 @@ def resolve_schema_dict(self, schema):
255254
256255
Examples: ::
257256
258-
#Input
257+
# Input
259258
{"type": "array", "items": "PetSchema"}
260259
261-
#Output
260+
# Output
262261
{"type": "array", "items": {"$ref": "#/components/schemas/Pet"}}
263262
264-
#Input
263+
# Input
265264
{"type": "object", "properties": {"pet": "PetSchcema", "user": "UserSchema"}}
266265
267-
#Output
266+
# Output
268267
{
269268
"type": "object",
270269
"properties": {
271270
"pet": {"$ref": "#/components/schemas/Pet"},
272-
"user": {"$ref": "#/components/schemas/User"}
273-
}
271+
"user": {"$ref": "#/components/schemas/User"},
272+
},
274273
}
275274
276275
:param string|Schema|dict schema: the schema to resolve.

0 commit comments

Comments
 (0)