Git Product home page Git Product logo

Comments (9)

roman-right avatar roman-right commented on May 17, 2024

Hey!
Thank you for the issue. This is a bug - fixed in the 1.7.1. Please, update

from beanie.

MovingEarth avatar MovingEarth commented on May 17, 2024

I tried 1.7.1 and revision_id has been removed from the output.
However, It is still in the schema, marked as hidden, and thus also appears in the example response
image
image
Is there anything we can do about that? Because now andybody who creates an api will have to explain to the user of the api what the purpose of revision_id.

from beanie.

roman-right avatar roman-right commented on May 17, 2024

Should be hidden there too now. Pls check 1.7.2

from beanie.

MovingEarth avatar MovingEarth commented on May 17, 2024

Yes, 1.7.2 totally resolves the visibility issue in output and schema. Thanks for your efforts.

More on a sidenote:
I noticed the field can still be 'used', so it is as the code calls it "hidden". So, when beanie is used in an API (say using FastAPI) the user of the api can still use the revision_id (although, if it is later no longer supported, not complain when it is removed as it is an undocumented api feature).
When the developer of the API wants to use the revision_id in the api, it has to be "un-hiden" (at this point, I would not know how, maybe by defining the field in my model?)

It might be completely against the philosophy of beanie (sorry I have not read the code yet), but it might be worth having these kind of features controlled from a config class of some sort like you see in other frameworks.
So the developer could write something like the code below to enable the revision_id:

class Note(Document):
    
    title: str
    text: Optional[str]

    class Config:
        use_revision_id = True

The idea being, by default "revision_id" is not used (not hidden, but really not used), but can be enabled using the config class.

This also gives you an opportunity to add new features in the future, which (by default) do not break an existing api generated by beanie (by adding of removing fields) and still allow the developer to adopt new features when needed / wanted.

from beanie.

roman-right avatar roman-right commented on May 17, 2024

Hey.
This make sense, but implementation could be tricky, as it is a pydantic field under the hood. I'll try to not use this field if the config is turned of soon.

Also, this feature is finally released. The doc about this could be found here: https://roman-right.github.io/beanie/tutorial/revision/

from beanie.

zrothberg avatar zrothberg commented on May 17, 2024

So this issue is a bit tricky. Its being caused by FastAPIs naive method of creating its document. I had to roll my own to get a functioning output. It was pretty easy to do I can see how portable to it is and if it is something I can port. The only issue becomes we would need to pin the pydantic version because its not code that is part of the API spec that needs to get replaced. Pydantic has a pretty slow release schedule so it is not that bad to do TBH.

from beanie.

github-actions avatar github-actions commented on May 17, 2024

This issue is stale because it has been open 30 days with no activity.

from beanie.

github-actions avatar github-actions commented on May 17, 2024

This issue was closed because it has been stalled for 14 days with no activity.

from beanie.

gsakkis avatar gsakkis commented on May 17, 2024

Not sure if it's the same issue but the inherited BaseModel.json() model still includes the revision_id.

from beanie.

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.