Fastapi: Swagger default Enum missing and Optional field also

Created on 23 Jul 2020  路  3Comments  路  Source: tiangolo/fastapi

SInce few days the default value provided for an ENUM is no more showing in the swagger

Before :
Screenshot from 2020-07-23 00-19-47

now:
Screenshot from 2020-07-23 00-20-04

@router.post('/a', response_model=Something)
async def endpoint_a(user: Something2,
                       keep_option: KeepOption = KeepOption.KEEP_NO_MISCLASSIFIED_ADS,
                       limit: Optional[int] = None):

Also a field limit:Optional[int] = None is not considered optional in the swagger

Screenshot from 2020-07-23 00-21-23

It's maybe only related to swagger-ui , do you have any idee ? thank you

question

Most helpful comment

Exactly
It seems to be due to a change of enum schema, which came in pydantic v1.6.
@mostaphaRoudsari made a very good statement in https://github.com/samuelcolvin/pydantic/pull/1749#issuecomment-662728965 to fix the doc generation.

All 3 comments

The problem seems to be in pydantic : https://github.com/samuelcolvin/pydantic/pull/1749

Exactly
It seems to be due to a change of enum schema, which came in pydantic v1.6.
@mostaphaRoudsari made a very good statement in https://github.com/samuelcolvin/pydantic/pull/1749#issuecomment-662728965 to fix the doc generation.

correct with pydantic 1.7

Was this page helpful?
0 / 5 - 0 ratings

Related issues

updatatoday picture updatatoday  路  3Comments

DrPyser picture DrPyser  路  3Comments

tsdmrfth picture tsdmrfth  路  3Comments

laith43d picture laith43d  路  3Comments

RogerioDosSantos picture RogerioDosSantos  路  3Comments