Skip to content

json.dumps in swagger_info will fail on datetime serialization  #94

Description

@nmatare

If the swagger_info attribute contains a datetime object in an example definition, the default JSON serializer will fail for datetime types.

ex)

TypeError: datetime.datetime(2021, 11, 14, 1, 34, 26, tzinfo=datetime.timezone(datetime.timedelta(0, 720))) is not JSON serializable

https://swagger.io/docs/specification/data-models/data-types/#string

swagger_info = json.dumps(swagger_info)

Proposing a PR to either:

  1. allow the caller to pass in a string, a pre-serialized spec;
  2. allow the caller to specify a user-defined serializer function; or
  3. something else.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions