Skip to content

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

Open
ramonski wants to merge 2 commits into
feature/partial-update-validationfrom
feature/introspection-endpoints
Open

Add introspection endpoints for types, schema and workflow#108
ramonski wants to merge 2 commits into
feature/partial-update-validationfrom
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 2 commits July 28, 2026 20:44
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 20947fb to 79c3772 Compare July 28, 2026 18:44
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.

1 participant