PoC: Built-in OpenAPI routing with controller.json#6248
Draft
joewiz wants to merge 4 commits intoeXist-db:developfrom
Draft
PoC: Built-in OpenAPI routing with controller.json#6248joewiz wants to merge 4 commits intoeXist-db:developfrom
joewiz wants to merge 4 commits intoeXist-db:developfrom
Conversation
Contributor
|
May I suggest that this should go into its own module. The exist-core module was created with the specific purpose of being slimmed down rather than made bigger, the previous plans was to remove everything from exist-core apart from core database engine. |
…module Add PackageManagementServlet, PackageService, and RepoPackageLoader in a new exist-services Maven module (not exist-core) per the architectural principle that exist-core should contain only the core database engine. The exist-services module provides built-in HTTP services for the eXist-db platform: package CRUD at /api/packages — list, get, install (registry + upload), remove (with dependency checking), update-check, icon serving. Compiled into the platform, no XAR dependency. Solves the self-upgrade problem that existdb-packageservice had. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…PoC)
Proof of concept for OpenAPI-native routing in eXist-db. Apps can use a
declarative controller.json + OpenAPI api.json spec to define REST
endpoints without Roaster or controller.xql.
New components:
- OpenApiServiceRegistry: in-memory routing table with path pattern
matching, scoped by collection
- OpenApiServlet: dispatches matched routes to XQuery handler functions
via operationId resolution (prefix:local-name convention)
- OpenApiTrigger: collection-level trigger that discovers controller.json
and api.json files and registers routes on storage events
- OpenApiStartupTrigger: scans /db/apps/ at startup for controller.json
files and pre-registers routes
Demo app included in test resources (openapi-demo/) showing a minimal
app with controller.json + api.json + hello.xqm handler module.
PoC URL space: /exist/openapi/{app}/... (production will integrate with
/exist/apps/ via XQueryURLRewrite fallback)
This is Phase 2 of the OpenAPI-native routing initiative. See
taskings/openapi-native-routing-tasking.md for the full design.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The servlet was treating all map results as Roaster-style response maps (with "code"/"body" keys), causing empty responses. Now it only treats maps as response maps if they contain "code" or "body" keys; otherwise it serializes them directly as JSON data. Also sets output properties (method=json) before creating the serializer and flushes the PrintWriter after serialization. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move OpenApiServlet, OpenApiServiceRegistry, OpenApiStartupTrigger, and OpenApiTrigger from exist-core to exist-services per the architectural principle that exist-core should contain only the core database engine. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
75aae5c to
97cde45
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add built-in OpenAPI routing to eXist-db via
controller.json+api.json. Apps define REST endpoints declaratively in an OpenAPI 3.0 spec; eXist automatically routes requests to XQuery handler functions byoperationId. This eliminates the need for Roaster and thecontroller.xql+api.xq+$lookupboilerplate.What Changed
All new code is in the
exist-servicesMaven module (notexist-core), per the architectural principle that exist-core should contain only the core database engine.New classes in
exist-services/OpenApiServiceRegistry.java— in-memory routing table with path pattern matchingOpenApiServlet.java— dispatches matched routes to XQuery handlersOpenApiStartupTrigger.java— scans/db/apps/at startup forcontroller.jsonOpenApiTrigger.java— collection trigger for auto-discovery on storage eventsConfiguration
web.xml— OpenApiServlet registrationcontroller-config.xml— URL pattern forwarding for/openapi/conf.xml— startup trigger registrationDemo app
exist-core/src/test/resources/openapi-demo/— three endpoints, no Roaster, no controller.xqlArchitecture
Relationship to PR #6247
This PR builds on #6247 (
feature/builtin-package-api). Both share theexist-servicesmodule.Test Plan
mvn install -pl exist-services -am -DskipTestscompiles cleanlycontroller.jsonroute correctly via OpenApiServlet🤖 Generated with Claude Code