How can we reflect the optional/required json items in documentation #8181
Replies: 10 comments
-
Are you asking about optional/required fields of the JSON body? |
Beta Was this translation helpful? Give feedback.
-
@haizaar - yes, that's about reflecting the optional/required json elements in the body for swagger documentation |
Beta Was this translation helpful? Give feedback.
-
It's working out of the box, if you use pydantic objects the generated schema will "translate" the requirements, for instance this pydantic object from the very beginning of the documentation (https://pydantic-docs.helpmanual.io/):
used this way:
shows in the documentation as So quoting pydantic doc, you can check
|
Beta Was this translation helpful? Give feedback.
-
which makes me think reading the spec on |
Beta Was this translation helpful? Give feedback.
-
@euri10, What if you define the handler as |
Beta Was this translation helpful? Give feedback.
-
if you do that @haizaar the red "required" next to the Request Body disappears |
Beta Was this translation helpful? Give feedback.
-
Which makes sense according to spec I assume, right?
…On Tue, 16 Jul 2019 at 23:47, euri10 ***@***.***> wrote:
if you do that @haizaar <https://github.com/haizaar> the red "required"
next to the Request Body disappears
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#388?email_source=notifications&email_token=AAAOGWKWBDHRVFEZ6MWYL2LP7XGNDA5CNFSM4IDVCTH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2A4ZBI#issuecomment-511822981>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAOGWJ3T34J5LV7OVBU5PTP7XGNDANCNFSM4IDVCTHQ>
.
--
Zaar
|
Beta Was this translation helpful? Give feedback.
-
yep indeed, seems like I got things reversed, like right and left, one day it'll be better :) |
Beta Was this translation helpful? Give feedback.
-
Hehe, thanks for the help @euri10 and @haizaar. And thanks @sl2016 for reporting back and closing the issue. |
Beta Was this translation helpful? Give feedback.
-
Description
How can I mark the optional/required json elements in the swagger documentation generated using FastAPI?
Currently, for POST verb, it just marked "* required" for the whole body and not individual json elements.
Beta Was this translation helpful? Give feedback.
All reactions