Giter VIP home page Giter VIP logo

Comments (3)

wing328 avatar wing328 commented on June 12, 2024 1

so if you remove/comment out the following:

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

the code works as expected?

from openapi-generator.

damzog avatar damzog commented on June 12, 2024

@wing328 no. In my case all obj passed to this class are instance of dict so this code is anyway noop. It does work if you omit the "not" meaning if you simply return return cls.model_validate(obj) . In that case pydantic will deserialize (one might to also need to assign the result to _obj)

from openapi-generator.

damzog avatar damzog commented on June 12, 2024

And as you can see

  _obj = cls.model_validate({
            "name": obj.get("name"),
            "address": Address.from_dict(obj.get("address")) if obj.get("address") is not None else None,
        })

filters out all entries from a dict that are not name, address which I do not understand why (sorry code snippet is not completely up to date. I removed address and added age in the example repo but it does not make a difference.)

from openapi-generator.

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.