File tree 6 files changed +30
-0
lines changed
samples/server/petstore/python-fastapi/src/openapi_server/models
6 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,11 @@ def from_dict(cls, obj: Dict) -> Self:
84
84
if not isinstance (obj , dict ):
85
85
return cls .model_validate (obj )
86
86
87
+ # raise errors for additional fields in the input
88
+ for _key in obj .keys ():
89
+ if _key not in cls .__properties :
90
+ raise ValueError ("Error due to additional fields (not defined in ApiResponse) in the input: " + _key )
91
+
87
92
_obj = cls .model_validate ({
88
93
"code" : obj .get ("code" ),
89
94
"type" : obj .get ("type" ),
Original file line number Diff line number Diff line change @@ -94,6 +94,11 @@ def from_dict(cls, obj: Dict) -> Self:
94
94
if not isinstance (obj , dict ):
95
95
return cls .model_validate (obj )
96
96
97
+ # raise errors for additional fields in the input
98
+ for _key in obj .keys ():
99
+ if _key not in cls .__properties :
100
+ raise ValueError ("Error due to additional fields (not defined in Category) in the input: " + _key )
101
+
97
102
_obj = cls .model_validate ({
98
103
"id" : obj .get ("id" ),
99
104
"name" : obj .get ("name" )
Original file line number Diff line number Diff line change @@ -98,6 +98,11 @@ def from_dict(cls, obj: Dict) -> Self:
98
98
if not isinstance (obj , dict ):
99
99
return cls .model_validate (obj )
100
100
101
+ # raise errors for additional fields in the input
102
+ for _key in obj .keys ():
103
+ if _key not in cls .__properties :
104
+ raise ValueError ("Error due to additional fields (not defined in Order) in the input: " + _key )
105
+
101
106
_obj = cls .model_validate ({
102
107
"id" : obj .get ("id" ),
103
108
"petId" : obj .get ("petId" ),
Original file line number Diff line number Diff line change @@ -109,6 +109,11 @@ def from_dict(cls, obj: Dict) -> Self:
109
109
if not isinstance (obj , dict ):
110
110
return cls .model_validate (obj )
111
111
112
+ # raise errors for additional fields in the input
113
+ for _key in obj .keys ():
114
+ if _key not in cls .__properties :
115
+ raise ValueError ("Error due to additional fields (not defined in Pet) in the input: " + _key )
116
+
112
117
_obj = cls .model_validate ({
113
118
"id" : obj .get ("id" ),
114
119
"category" : Category .from_dict (obj .get ("category" )) if obj .get ("category" ) is not None else None ,
Original file line number Diff line number Diff line change @@ -83,6 +83,11 @@ def from_dict(cls, obj: Dict) -> Self:
83
83
if not isinstance (obj , dict ):
84
84
return cls .model_validate (obj )
85
85
86
+ # raise errors for additional fields in the input
87
+ for _key in obj .keys ():
88
+ if _key not in cls .__properties :
89
+ raise ValueError ("Error due to additional fields (not defined in Tag) in the input: " + _key )
90
+
86
91
_obj = cls .model_validate ({
87
92
"id" : obj .get ("id" ),
88
93
"name" : obj .get ("name" )
Original file line number Diff line number Diff line change @@ -89,6 +89,11 @@ def from_dict(cls, obj: Dict) -> Self:
89
89
if not isinstance (obj , dict ):
90
90
return cls .model_validate (obj )
91
91
92
+ # raise errors for additional fields in the input
93
+ for _key in obj .keys ():
94
+ if _key not in cls .__properties :
95
+ raise ValueError ("Error due to additional fields (not defined in User) in the input: " + _key )
96
+
92
97
_obj = cls .model_validate ({
93
98
"id" : obj .get ("id" ),
94
99
"username" : obj .get ("username" ),
You can’t perform that action at this time.
0 commit comments