Skip to content

[IMP] endpoint: request content schema#131

Open
ivantodorovich wants to merge 2 commits intoOCA:19.0from
camptocamp:endpoint-request-content-schema
Open

[IMP] endpoint: request content schema#131
ivantodorovich wants to merge 2 commits intoOCA:19.0from
camptocamp:endpoint-request-content-schema

Conversation

@ivantodorovich
Copy link
Copy Markdown

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

@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @simahawk,
some modules you are maintaining are being modified, check this out!

@ivantodorovich ivantodorovich force-pushed the endpoint-request-content-schema branch from 13eee45 to 97682fc Compare April 30, 2026 19:04
@ivantodorovich ivantodorovich force-pushed the endpoint-request-content-schema branch from 97682fc to c5c2b78 Compare April 30, 2026 19:07
Copy link
Copy Markdown
Contributor

@simahawk simahawk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README to be updated

)
) from exception

def _check_request_content_schema_xml(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

@ivantodorovich ivantodorovich marked this pull request as ready for review May 6, 2026 13:52
@ivantodorovich
Copy link
Copy Markdown
Author

@simahawk I added the configure section in the readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants