[IMP] endpoint: request content schema#131
Conversation
|
Hi @simahawk, |
13eee45 to
97682fc
Compare
97682fc to
c5c2b78
Compare
| ) | ||
| ) from exception | ||
|
|
||
| def _check_request_content_schema_xml(self): |
There was a problem hiding this comment.
We have plenty of XSD files in modules: we should be able to provide a path too.
If you don't want to add a specific field for this, we could use a prefix path:.
There was a problem hiding this comment.
What use case do you have in mind?
IMO if you want to specify the schema in a different file, it can be covered with standard Odoo xml import, like this.
<record id="endpoint_demo" model="endpoint.endpoint">
<field name="name">Demo Endpoint</field>
<field name="route">/demo</field>
<field name="request_method">POST</field>
<field name="exec_mode">code</field>
<field name="code_snippet">result = {"response": Response("Hello, World!")}</field>
<field name="request_content_type">application/xml</field>
<field name="request_content_schema" type="char" file="endpoint/demo/content_schema.xsd" />
</record>There was a problem hiding this comment.
that won't work from the UI.
The use case is: I have a URL to XSD or an attachment: how would I use it here w/o copy/pasting its content?
I would at list allow to select an existing attachment instead w/ domain filter on *.xsd files.
There was a problem hiding this comment.
For a pure UI created record, I think it's not that problematic if the user copy&paste the content directly in the field. There's no benefit in having a separate attachment for this, in fact in practice it will make it slower due to binary reads than just having its content in the DB.
I rather not add a magic syntax like "path:" to the field content. IMO, the schema field content should be a pure schema definition, either XSD or JSON schema (or something else in the future for other content types), not a magic thing built on top.
So, if we were to do this cleanly, I'd go for a request_content_schema_source and separate fields for each source type. But, honestly, it's seems overly complicated to avoid a copy&paste...
|
@simahawk I added the configure section in the readme |
Implement request content validation through an optional schema.
For
application/json, we use the JSON Schema (same than openapi)For
application/xml, we use XSD Schema