Skip to content

Add introspection endpoints for types, schema and workflow - #108

Merged
xispa merged 4 commits into
2.xfrom
feature/introspection-endpoints
Oct 14, 2026
Merged

xispa merged 4 commits into
2.xfrom
feature/introspection-endpoints

Conversation

@ramonski

@ramonski ramonski commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Description of the issue/feature this PR addresses

There is currently no way for an API client to discover the data model. To create or update content it has to know the exact portal type name, the field names and their types up front, which in practice means scraping the add/edit forms in the UI (for example to learn that the type is AnalysisSpec, not AnalysisSpecification, or that a Sample's specification lives on a single valued reference field). This adds three read-only introspection routes. They are schema and FTI driven, so custom add-on types (including ones with their own catalog and add permission) are covered without special casing.

GET /senaite/v1/types lists the registered portal types. Pass parent_uid or parent_path to restrict the listing to the types that can be added inside that container (this honors programmatic constraints, so a restricted type such as a custom order type only shows up under the containers that actually allow it).

GET /senaite/v1/types/<portal_type> describes a single portal type: title, description, meta type, global_allow (whether it is addable anywhere or only where a container allows it), the add_permission, and the catalogs that index it.

GET /senaite/v1/schema/<portal_type> describes the schema fields: name, type, whether the field is required or read only, whether it is multi valued, and for reference fields the portal types it may point to. Works for both Archetypes content (introspected from an existing instance) and Dexterity content, including behavior fields.

GET /senaite/v1/workflow/<uid> returns the current review state and the available transitions of an object, so a client can answer "what can I do with this now" without guessing transition ids.

Current behavior before PR

No type, schema or workflow introspection is exposed by the API.

Desired behavior after PR is merged

The four routes above are available and covered by a new introspect.rst doctest.

--
I confirm I have coded it according to PEP8 standards.

ramonski added a commit that referenced this pull request Jul 28, 2026
@ramonski
ramonski requested a review from xispa July 28, 2026 18:38
@ramonski ramonski added Feature 🪚 New feature request Enhancement ✨ Improvement to existing functionality labels Jul 28, 2026
ramonski added a commit that referenced this pull request Jul 28, 2026
@ramonski
ramonski force-pushed the feature/introspection-endpoints branch from 8fb6103 to 20947fb Compare July 28, 2026 18:42
@ramonski
ramonski changed the base branch from 2.x to feature/partial-update-validation July 28, 2026 18:42
ramonski added a commit that referenced this pull request Jul 28, 2026
@ramonski
ramonski force-pushed the feature/introspection-endpoints branch from 20947fb to 79c3772 Compare July 28, 2026 18:44
@ramonski
ramonski force-pushed the feature/partial-update-validation branch from 9bd7a20 to 5b7828f Compare October 6, 2026 11:27
ramonski added a commit that referenced this pull request Oct 6, 2026
@ramonski
ramonski force-pushed the feature/introspection-endpoints branch from 79c3772 to 9c1daea Compare October 6, 2026 11:27
@ramonski
ramonski force-pushed the feature/partial-update-validation branch from 5b7828f to 23fa4d2 Compare October 6, 2026 11:28
ramonski added a commit that referenced this pull request Oct 6, 2026
@ramonski
ramonski force-pushed the feature/introspection-endpoints branch from 9c1daea to 1f7f37d Compare October 6, 2026 11:28
update_object_with_data re-validated the whole object after applying
the record. The field managers already validate each submitted field on
set, so that second pass only re-checks untouched fields, and fails when
one of them no longer passes a full validation on its own: an Archetypes
field holding a stored legacy value, or a Dexterity behavior invariant
such as IExcludeFromNavigationDefault. A partial update of a setup
object was refused even when the submitted field itself was fine.

Creation still validates the whole object, which is what #66 is about.

Rewritten against the current 2.x: the route helpers moved to
api/mutation in #97 after this change was first written.
@ramonski
ramonski force-pushed the feature/partial-update-validation branch from 23fa4d2 to 8b53ce3 Compare October 6, 2026 11:29
ramonski added a commit that referenced this pull request Oct 6, 2026
@ramonski
ramonski force-pushed the feature/introspection-endpoints branch from 1f7f37d to 8a2f1aa Compare October 6, 2026 11:29
Adds three read-only routes so a client can discover the data model instead
of scraping the UI:

/types                list the portal types (optionally addable in a
                      container via parent_uid / parent_path)
/types/<portal_type>  describe a single portal type, including the catalogs
                      that index it and the permission required to add it
/schema/<portal_type> describe the schema fields (type, required, readonly,
                      and reference target types), for both Archetypes and
                      Dexterity content
/workflow/<uid>       the current review state and the available transitions
@ramonski
ramonski force-pushed the feature/introspection-endpoints branch from 8a2f1aa to f9a07b2 Compare October 7, 2026 05:42
Base automatically changed from feature/partial-update-validation to 2.x October 14, 2026 14:24

@xispa xispa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is really handy!

@xispa
xispa merged commit 272cddd into 2.x Oct 14, 2026
2 checks passed
@xispa
xispa deleted the feature/introspection-endpoints branch October 14, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement ✨ Improvement to existing functionality Feature 🪚 New feature request

Development

Successfully merging this pull request may close these issues.

2 participants