Skip to content

Commit 28586c9

Browse files
committed
chore: reflected additional fields in yaml spec example
1 parent 51a75d7 commit 28586c9

2 files changed

Lines changed: 70 additions & 1 deletion

File tree

tests/data/swagger.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ paths:
5656
- Users
5757
requestBody:
5858
$ref: '#/components/requestBodies/AddUserRequest'
59+
callbacks:
60+
onAdd:
61+
'{$request.body#/email}':
62+
post:
63+
summary: 'Callback after user creation'
64+
responses:
65+
'200':
66+
description: 'Callback processed successfully'
5967
responses:
6068
201:
6169
$ref: '#/components/responses/AddUserResponse'
@@ -109,6 +117,7 @@ components:
109117
allowEmptyValue: false
110118
example: 10
111119
required: true
120+
allowReserved: true
112121
schema:
113122
type: integer
114123

@@ -155,6 +164,12 @@ components:
155164
application/json:
156165
schema:
157166
$ref: '#/components/schemas/User'
167+
encoding:
168+
login:
169+
contentType: text/plain
170+
style: form
171+
email:
172+
contentType: text/plain
158173

159174
responses:
160175
BadRequest:
@@ -215,6 +230,12 @@ components:
215230
properties:
216231
user:
217232
$ref: '#/components/schemas/User'
233+
links:
234+
UpdateUser:
235+
operationId: UpdateUser
236+
parameters:
237+
uuid: '$response.body#/user/uuid'
238+
description: Updates the user
218239

219240
schemas:
220241
BadRequestError:
@@ -249,6 +270,7 @@ components:
249270

250271
UUIDObject:
251272
type: object
273+
additionalProperties: false
252274
required:
253275
- uuid
254276
properties:

tests/openapi_fixture.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
Array,
1616
Contact,
1717
Content,
18+
Encoding,
1819
Info,
1920
Integer,
2021
License,
22+
Link,
2123
Object,
2224
Operation,
2325
Parameter,
@@ -35,6 +37,7 @@
3537

3638
schema_user = Object(
3739
type=DataType.OBJECT,
40+
additional_properties=False,
3841
required=["uuid", "login", "email", "avatar"],
3942
properties=[
4043
Property(
@@ -242,6 +245,7 @@ def create_specification() -> Specification:
242245
),
243246
"UUIDObject": Object(
244247
type=DataType.OBJECT,
248+
additional_properties=False,
245249
required=["uuid"],
246250
properties=[
247251
Property(
@@ -257,6 +261,7 @@ def create_specification() -> Specification:
257261
),
258262
"User": Object(
259263
type=DataType.OBJECT,
264+
additional_properties=False,
260265
required=["uuid", "login", "email", "avatar"],
261266
properties=[
262267
Property(
@@ -334,6 +339,7 @@ def create_specification() -> Specification:
334339
required=True,
335340
explode=True,
336341
style=QueryParameterStyle.FORM,
342+
allow_reserved=True,
337343
example=10,
338344
schema=Integer(type=DataType.INTEGER),
339345
),
@@ -389,8 +395,38 @@ def create_specification() -> Specification:
389395
security=[{"Basic": []}],
390396
request_body=RequestBody(
391397
description="New user model request",
392-
content=[Content(type=ContentType.JSON, schema=schema_user)],
398+
content=[
399+
Content(
400+
type=ContentType.JSON,
401+
schema=schema_user,
402+
encoding={
403+
"login": Encoding(
404+
content_type="text/plain",
405+
style="form",
406+
),
407+
"email": Encoding(
408+
content_type="text/plain",
409+
),
410+
},
411+
)
412+
],
393413
),
414+
callbacks={
415+
"onAdd": {
416+
"{$request.body#/email}": {
417+
"post": {
418+
"summary": "Callback after user creation",
419+
"responses": {
420+
"200": {
421+
"description": (
422+
"Callback processed successfully"
423+
),
424+
},
425+
},
426+
},
427+
},
428+
},
429+
},
394430
responses=[
395431
Response(
396432
code=201,
@@ -449,6 +485,17 @@ def create_specification() -> Specification:
449485
),
450486
),
451487
],
488+
links={
489+
"UpdateUser": Link(
490+
operation_id="UpdateUser",
491+
parameters={
492+
"uuid": (
493+
"$response.body#/user/uuid"
494+
),
495+
},
496+
description="Updates the user",
497+
),
498+
},
452499
),
453500
bad_request_response,
454501
internal_error_response,

0 commit comments

Comments
 (0)