jmcarp / flask-apispec

MIT License
655 stars 156 forks source link

use_kwargs with fields.DateTime is parsed as string #227

Open thebino opened 3 years ago

thebino commented 3 years ago

When using fields.DateTime in a use_kwargs it is rendered as string in swagger/openapi.

@use_kwargs(
    {
        'from': fields.DateTime(
            format="rfc",
            default=datetime.datetime.now(),
            description="The timestamp a vehicle should be available from"
        )
    }, location='query')
Screenshot 2021-09-22 at 21 42 33

When using it inside the swagger editor, it is rendered as string($date-time)

Screenshot 2021-09-22 at 21 43 11

This is more conclusive for developers since the string has a specific format.

thebino commented 3 years ago

More precisely it only happens when using openapi_version='3.0.0' when switching to version 2.0.0 it looks normal.

app.config['APISPEC_SPEC'] = apispec.APISpec(
    title='Vehicles booking API',
    version='1.0.0',
    openapi_version='3.0.0',