Giter Site home page Giter Site logo

Comments (3)

fuhrysteve avatar fuhrysteve commented on June 1, 2024 1

Hmm, so I have a fix for this - however in your example, uuid.UUID is not serializable either

 34     def test_default_callable():
 35         class DefaultCallableSchema(Schema):
 36             uuid = fields.UUID(default=uuid.uuid4)
 37  
 38         dumped = JSONSchema().dump(DefaultCallableSchema())
 39  
 40         props = dumped["definitions"]["DefaultCallableSchema"]["properties"]
 41         import pdb; pdb.set_trace()
 42  ->     uuid.UUID(props["uuid"]["default"])
(Pdb) pp props
{'uuid': {'default': UUID('253646fa-5ec3-49e7-8d64-9af77c2b982a'),
          'format': 'uuid',
          'title': 'uuid',
          'type': 'string'}}
(Pdb) import json
(Pdb) json.dumps(props)
*** TypeError: Object of type UUID is not JSON serializable

from marshmallow-jsonschema.

kaos avatar kaos commented on June 1, 2024

Oops. That's right. I'll usually have to use a custom json encoder to take care of uuid, datetime and the like.. not sure what approach would be suitable here.

from marshmallow-jsonschema.

kaos avatar kaos commented on June 1, 2024

That is actually a separate issue from this one, that there may be data in the schema that is not straight off dumpable with json.dumps.

from marshmallow-jsonschema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.