[UNOMI-963] Enrich OpenAPI from Javadoc via openapi-enrich 0.1.0 - #826
Merged
Conversation
Wire openapi-enrich into rest/extensions and add @api.status / @api.example plus schema field docs so /cxs/openapi.json is Client/Swagger-ready (live gold excl. /api-docs).
Replace 0.1.0-SNAPSHOT so CI can resolve the published toolkit.
Contributor
Author
|
Note for reviewers: UNOMI-963’s JIRA summary still said “with Swagger annotations” historically. The implementation (and the ticket rewrite in flight) uses Javadoc + |
Pin the released Central artifacts and keep JAX-RS startup if enrichment pack loading fails.
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.
Plain-language summary
Unomi already exposes OpenAPI at
/cxs/openapi.json(and Swagger UI), but what CXF generated from JAX-RS annotations alone was a thin skeleton: generic"default response"texts, few usable examples, and schemas that often showed Java internals instead of the JSON clients actually send (for example Condition showingconditionTypeId/ nested type objects instead of the wiretype+parameterValuesshape).This PR closes that gap by treating Javadoc as the source of truth for OpenAPI. At build time we generate enrichment packs; at runtime CXF merges them into the OpenAPI document. Developers get a Swagger UI and machine-readable contract they can trust when integrating against Unomi—without changing REST behavior.
Toolkit: openapi-enrich (
dev.inoyu.openapi:*:0.1.0) — developed for these Unomi needs and open-sourced by Inoyu (Apache-2.0). See the excellent README; published on Maven Central (not vendored in the ASF tree).Toolkit (Inoyu)
openapi-enrich (
dev.inoyu.openapi:*:0.1.0) was built for this Unomi requirement: enrich a CXF + OSGi live OpenAPI from Javadoc, without mass Swagger@Operation/@Schemaannotations that would duplicate and drift from existing docs.Inoyu (inoyu.dev) open-sourced the toolkit under Apache-2.0 on Maven Central. Unomi consumes the published JARs/plugin like any other dependency—it does not vendor the toolkit sources inside the ASF tree.
Gold coverage (definition + scope of work)
What “gold” means
We score each HTTP operation in live
/cxs/openapi.jsonas:200/204/400) with a real description (not empty /"default response"), and the operation includes at least one response exampleThat is the bar where Swagger UI and client codegen stop being guesswork: callers see what can happen and what a valid body looks like.
Result on this branch
GET /api-docs/{resource}, skipped on purpose — Swagger helper, not a product API).type+parameterValues; EventprofileId/sessionId(no leaked nested/transient junk).Work that got us there
This was not a thin status-only pass. It covered the full JAX-RS-ish inventory (~180 ops) plus schema correctness:
openapi-enrich0.1.0: Javadoc/@api.*scan, inheritance, wire aliases, transient suppress, overloads, path-regex normalize, servlet merge; released to Maven Central so CI resolves a release.{items:.*}/ query metrics paths) got context-specific@api.examplevalues (entity illustrations,context.jsJS snippet, export CSV, booleans/maps where appropriate)—examples are domain-relevant, not filler.Effort (planning bands from the work tracker): toolkit MVP on the order of ~4–8 person-days; Unomi hot-path content ~4–7 person-days; full Tenant-quality inventory across mid/thin/extensions was an additional multi-day content push, plus the final live gold example sweep.
Why this matters for developers
setPropertyAction, context.js payload, CSV export, …)@XmlTransientleftovers)type+parameterValues— the shape clients must POSTWho benefits: integration engineers building against
/cxs/*, contributors validating APIs in Swagger, authors of migration/tools/tests that rely on the published contract, and anyone generating typed clients fromopenapi.json.Approach (how it works)
@api.status CODE [array] SchemaFqcn|empty Description@api.example …(response / empty-body illustration)openapi-enrich-maven-pluginscans sources → pack underMETA-INF/openapi-enrich/.EnrichingOpenApiCustomizer(embedded inunomi-rest) merges packs into CXF’s OpenAPI at runtime (core + OSGi extension packs).Unomi only wires the toolkit and supplies content. Correctness features that made the live doc accurate (aliases, transient suppression, inherited JAX-RS methods, path-regex normalize, subclass override docs) live in the Central library.
Not in scope for enrichment:
GET /api-docs/{resource}(Swagger helper, not a product API).What changed in this PR
${openapi.enrich.version}→0.1.0(Maven Central — required for CI).rest+ extension REST modules; embed enricher + model;RestServerregisters the customizer.@api.status/@api.example+ schema field docs across hot paths (context, eventcollector, profiles, rules, segments, privacy), mid/thin REST, and extensions (geonames, lists, json-schema, router import/export, groovy, SFDC, healthcheck).Reviewer guide
pom.xml+rest/pom.xml0.1.0pin, Mojo, Embed-Dependencyrest/.../RestServer.javaTenantEndpoint.java,ContextJsonEndpoint.java,RulesServiceEndPoint.javaextensions/geonames/.../GeonamesEndPoint.javarestMost other files are mechanical Javadoc following those exemplars—sample a few prefixes rather than reading every line.
Before / after (conceptual)
Before (typical CXF stock):
200→"default response", Condition properties include transient/internal names, little or no request/response example.After (enriched):
Documented statuses (e.g. rule save
204/ invalid body400), Condition/Action examples using"type":"eventTypeCondition"/"type":"setPropertyAction", field examples on Profile/Event/Query/PartialList, workable Swagger “try it out”.Live check used for this branch: 179/179 operations gold excluding
/api-docs(see Gold coverage above for the definition and work scope).Test plan
/cxs/openapi.jsongold excl./api-docs; Condition/Action wire keys verifiedcxf-openapi-enricher/openapi-enrich-model/ maven-plugin0.1.0)/cxs/context.json,/cxs/profiles,/cxs/rules,/cxs/geonames/...References