File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
tests/test_tutorial/test_dataclasses Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1+ from copy import deepcopy
2+
13from fastapi .testclient import TestClient
24
35from docs_src .dataclasses .tutorial002 import app
2931 "schemas" : {
3032 "Item" : {
3133 "title" : "Item" ,
32- "required" : ["name" , "price" , "tags" ],
34+ "required" : ["name" , "price" ],
3335 "type" : "object" ,
3436 "properties" : {
3537 "name" : {"title" : "Name" , "type" : "string" },
5153def test_openapi_schema ():
5254 response = client .get ("/openapi.json" )
5355 assert response .status_code == 200
54- assert response .json () == openapi_schema
56+ # TODO: remove this once Pydantic 1.9 is released
57+ # Ref: https://github.com/samuelcolvin/pydantic/pull/2557
58+ data = response .json ()
59+ alternative_data1 = deepcopy (data )
60+ alternative_data2 = deepcopy (data )
61+ alternative_data1 ["components" ]["schemas" ]["Item" ]["required" ] = ["name" , "price" ]
62+ alternative_data2 ["components" ]["schemas" ]["Item" ]["required" ] = [
63+ "name" ,
64+ "price" ,
65+ "tags" ,
66+ ]
67+ assert alternative_data1 == openapi_schema or alternative_data2 == openapi_schema
5568
5669
5770def test_get_item ():
You can’t perform that action at this time.
0 commit comments