File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed
expected/openapi/default_template/body_and_parameters Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,18 @@ def request(self) -> Optional[Argument]:
143143 )
144144 )
145145 self .imports .extend (data_type .imports_ )
146-
146+ elif content_type == 'application/x-www-form-urlencoded' :
147+ arguments .append (
148+ # TODO: support form with `Form()`
149+ Argument (
150+ name = 'request' , # type: ignore
151+ type_hint = 'Request' , # type: ignore
152+ required = True ,
153+ )
154+ )
155+ self .imports .append (
156+ Import .from_full_path ('starlette.requests.Request' )
157+ )
147158 if not arguments :
148159 return None
149160 return arguments [0 ]
Original file line number Diff line number Diff line change 77from typing import List , Optional
88
99from fastapi import FastAPI , Query
10+ from starlette .requests import Request
1011
1112from .models import (
1213 Pet ,
2526)
2627
2728
29+ @app .post ('/bar' , response_model = None )
30+ def post_bar (request : Request ) -> None :
31+ """
32+ Create a bar
33+ """
34+ pass
35+
36+
2837@app .get ('/foo' , response_model = str )
2938def get_foo (foo : Optional [str ] = None ) -> str :
3039 pass
Original file line number Diff line number Diff line change @@ -213,6 +213,16 @@ paths:
213213 type : string
214214 parameters :
215215 - $ref : ' #/components/parameters/MyParam'
216+ /bar :
217+ post :
218+ summary : Create a bar
219+ tags :
220+ - bar
221+ requestBody :
222+ content :
223+ application/x-www-form-urlencoded :
224+ schema :
225+ $ref : ' #/components/schemas/PetForm'
216226 /user :
217227 get :
218228 tags :
You can’t perform that action at this time.
0 commit comments