Giter VIP home page Giter VIP logo

Comments (2)

antoni-jamiolkowski avatar antoni-jamiolkowski commented on September 27, 2024

Hi,

Out of my own curiosity, I decided to do a little investigation ... It turns out that the event of the unexpected deletion in your example happens in the handle_ref_overrides method of the GenerateJsonSchema class (link to the exact line).

The documentation of the method partially explains a notion of deleting sibling keys (here key title with value "MyInnerModel" in inner_1 and MyInnerModel). I am not fluent in the doings of the Pydantic's schema generation so unfortunately I can't provide you with explanation nor fix.

Since I spend some time on this issue I will try to delve into this topic if I find some free time and no one else has addressed your question yet 🙂

But at the moment, my money is on this being an expected behavior. I believe that what the Field(title="...") does is some kind of renaming of the title of MyInnerModel type, which by default is a class' name. The title of the MyInnerModel type in the inner_1 is handled by the $ref to the MyInnerModel class, hence the missing "title" key in the schema["properties"]["inner_1"].

from pydantic.

sydney-runkle avatar sydney-runkle commented on September 27, 2024

Hi folks!

I believe @antoni-jamiolkowski is on the right track here - I think this is the expected behavior - the title is by default the class name, so during JSON schema generation, we remove redundant title information. I think if you want to retain the redundancy, custom JSON schema generation would be the best route to go for now!

from pydantic.

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.