Comments (6)
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.
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.
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.
I'm really not against the idea! I just think that:
- it would be a bit presumptuous to think that we could have a better validation than Notion's one on the client's side
- 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.
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.
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)
- can't find properties of "Remind"
- Sample query doesn't work, return empty result HOT 4
- [error] AttributeError: 'str' object has no attribute 'logger' HOT 2
- How to read the `block` text?
- Type hints HOT 2
- Logging configuration does not work HOT 2
- notion_client does not work in a class under multiprocessing HOT 2
- notion.databases.create: Is it possible to rearrange database fields according to some defined order? HOT 2
- Using asyncio for notion.pages.create requests HOT 1
- httpx 0.25.x is not compatible with notion client: "TypeError: ConnectionPool.__init__() got an unexpected keyword argument 'socket_options'" HOT 4
- Image upload error when create a new notion page HOT 1
- Alternative for `DatabasesEndpoint.list()` HOT 1
- Create database entry with `select` property HOT 1
- Deleting an icon or a cover is not possible.
- Switch to Ruff HOT 1
- iterate_paginated_api and api_endpoints#query seems to be broken in 2.2.0 HOT 3
- notion.blocks.append not accessible HOT 1
- Database query malformed schema HOT 1
- Wrong response when querying database rollup field with ascending/descending sort HOT 2
- Add Type Hints to Response and Arguments of a function HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notion-sdk-py.