Skip to content

Commit 3f82148

Browse files
committed
Bug: unmarshalling not working when there is no type: object.
1 parent c1e9f72 commit 3f82148

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

tests/integration/data/v3.0/petstore.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,16 @@ components:
287287
type: integer
288288
format: int64
289289
PetCreate:
290-
type: object
291-
x-model: PetCreate
290+
# type: object
292291
allOf:
293292
- $ref: "#/components/schemas/PetCreatePartOne"
294-
- $ref: "#/components/schemas/PetCreatePartTwo"
295-
oneOf:
296-
- $ref: "#/components/schemas/Cat"
297-
- $ref: "#/components/schemas/Bird"
293+
- type: object
294+
properties:
295+
birth_date:
296+
type: string
297+
format: date
298298
PetCreatePartOne:
299299
type: object
300-
x-model: PetCreatePartOne
301300
required:
302301
- name
303302
properties:

tests/integration/validation/test_petstore.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
from base64 import b64encode
3+
from datetime import date
34
from datetime import datetime
45
from uuid import UUID
56

@@ -550,6 +551,39 @@ def test_get_pets_param_coordinates(self, spec):
550551

551552
assert body is None
552553

554+
def test_birth_date(self, spec):
555+
host_url = "https://staging.gigantic-server.com/v1"
556+
path_pattern = "/v1/pets"
557+
headers = {
558+
"api-key": self.api_key_encoded,
559+
}
560+
cookies = {
561+
"user": "123",
562+
"userdata": {
563+
"name": "user1",
564+
},
565+
}
566+
567+
data_json = {
568+
"name": "required",
569+
"birth_date": "2022-09-18"
570+
}
571+
data = json.dumps(data_json)
572+
573+
request = MockRequest(
574+
host_url,
575+
"POST",
576+
"/pets",
577+
path_pattern=path_pattern,
578+
data=data,
579+
headers=headers,
580+
cookies=cookies,
581+
)
582+
583+
body = spec_validate_body(spec, request)
584+
585+
assert isinstance(body["birth_date"], date)
586+
553587
def test_post_birds(self, spec, spec_dict):
554588
host_url = "https://staging.gigantic-server.com/v1"
555589
path_pattern = "/v1/pets"

0 commit comments

Comments
 (0)