Giter Site home page Giter Site logo

Client-side validation about notion-sdk-py HOT 6 CLOSED

ramnes avatar ramnes commented on May 18, 2024
Client-side validation

from notion-sdk-py.

Comments (6)

ramnes avatar ramnes commented on May 18, 2024

Why not just let the API tell you the error?

Validating bodies would make the codebase much larger and harder to maintain; I really want to make sure it has a lot of benefits for users before going down this route.

from notion-sdk-py.

zxjlm avatar zxjlm commented on May 18, 2024

Thanks for your response.

I am now writing a project that can convert books to notion type. and i got the error blow.

APIResponseError: body failed validation: body.children[0].bulleted_list_item.children[1].paragraph.children[0].bulleted_list_item.children should be not present

But i didn`t find the detail of validate rule in notion api page.

Is this data structure too deeply nested? so i want to get the rule notion used.

In addition to this, i think that local validation will benifit the unit test. The request made by UT is of no value to the notion server.

All of the above are personal opinions, if you think it is unnecessary, i will close this issue.

Finally, looking forward to your answer to question marked in bolded format.

from notion-sdk-py.

zxjlm avatar zxjlm commented on May 18, 2024

Here is the data i used.

[
    {
        "type":"bulleted_list_item",
        "bulleted_list_item":{
            "text":[

            ],
            "children":[
                {
                    "type":"paragraph",
                    "paragraph":{
                        "text":[
                            {
                                "type":"text",
                                "text":{
                                    "content":"用户接口层",
                                    "link":null
                                }
                            }
                        ]
                    }
                },
                {
                    "type":"paragraph",
                    "paragraph":{
                        "text":[
                            {
                                "type":"text",
                                "text":{
                                    "content":"",
                                    "link":null
                                }
                            }
                        ],
                        "children":[
                            {
                                "type":"bulleted_list_item",
                                "bulleted_list_item":{
                                    "text":[
                                        {
                                            "type":"text",
                                            "text":{
                                                "content":"Assembler :将 CustomerDTO 转换为 CustomerEntity",
                                                "link":null
                                            }
                                        }
                                    ],
                                    "children":[

                                    ]
                                }
                            },
                            {
                                "type":"bulleted_list_item",
                                "bulleted_list_item":{
                                    "text":[
                                        {
                                            "type":"text",
                                            "text":{
                                                "content":"Dto:接收请求传入的数据 CustomerDTO",
                                                "link":null
                                            }
                                        }
                                    ],
                                    "children":[

                                    ]
                                }
                            },
                            {
                                "type":"bulleted_list_item",
                                "bulleted_list_item":{
                                    "text":[
                                        {
                                            "type":"text",
                                            "text":{
                                                "content":"Facade:调用应用层创建用户方法",
                                                "link":null
                                            }
                                        }
                                    ],
                                    "children":[

                                    ]
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
]

from notion-sdk-py.

ramnes avatar ramnes commented on May 18, 2024

I'm really not against the idea! I just think that:

  1. it would be a bit presumptuous to think that we could have a better validation than Notion's one on the client's side
  2. I really don't have enough bandwidth to maintain compatibility with their changes on such a fine grained level

Now, notion-sdk-js does seem to define the whole validation structures in their api-endpoints.ts file, so maybe we could use that with something like Js2Py, but that sounds quite experimental.

from notion-sdk-py.

zxjlm avatar zxjlm commented on May 18, 2024

All validation occurs after the post\patch request has been sent. But I need a stateless validation.

So notion-sdk-js can achieve my goals. Js2Py is one way. Also I can edit the code and make a node.js micro-service to use notion`s rule to validate my data structure.

Thank you for helping me find the way to solve the problem ~

from notion-sdk-py.

ramnes avatar ramnes commented on May 18, 2024

You're welcome! If you end up using Js2Py, please keep me updated as I would love to see if that can be achieved that way.

from notion-sdk-py.

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.