Replies: 4 comments
|
Thanks for putting together this thoughtful proposal. As one of the original contributors and maintainers of Gravitino’s OpenAPI module, I agree with the problem statement and support the overall direction of making OpenAPI the authoritative external contract for API V2. The current OpenAPI module was initially introduced mainly to document and manage REST API definitions. It was not designed as an executable source of truth or as the basis for server/client generation. Evolving it into a stronger contract is reasonable as Gravitino’s API surface and non-Java ecosystem grow. That said, I do not think the proposal is implementation-ready yet. It currently combines three related but distinct efforts:
These efforts should be coordinated, but they should not block one another. In particular, important V1 error-handling improvements should not wait for V2. I also suggest keeping the model strategy open. Making OpenAPI authoritative does not necessarily require generating all request/response models or introducing a completely separate model hierarchy. For example, Apache Polaris generates JAX-RS service interfaces from OpenAPI while mapping schema types to Iceberg’s maintained REST models. Other approaches are also viable. We should validate the trade-offs before committing to one architecture. My recommendation is to start with a narrow Catalog/Table vertical slice and use it to answer the remaining design questions:
Therefore, my position is +1 on the direction and on starting a focused design/PoC, but I would not yet treat the full V2 migration or translation-layer architecture as decided. A small end-to-end prototype should give us the evidence needed to make those decisions confidently. |
|
Clarification: Mark correctly pointed out that Gravitino already publishes rendered OpenAPI documentation: https://gravitino.apache.org/docs/latest/api/rest/gravitino-rest-api/ My point was more specific: the long-term North Star is to expose a stable, versioned, machine-readable OpenAPI document that clients and tooling can consume directly—for example:
This complements the existing documentation rather than replacing it. |
|
I want to clarify something:
|
|
Hi all — I wrote up a proposal for making OpenAPI the authoritative external contract for Gravitino API V1. I’d appreciate discussion and iteration on the approach. I’ll try to get an end-to-end PoC implementation going on my fork. |
Uh oh!
There was an error while loading. Please reload this page.
Two birds with one stone
Abstract
I recommend adopting OpenAPI as the authoritative external contract for Gravitino API V2 and integrating that contract into the server’s development, testing, and release lifecycle.
This addresses two related problems:
A specification-first V2 would give us a stable external contract, enable non-Java integrations and generated clients, improve error semantics, and support conformance testing, property-based testing, API fuzzing, and automated regression detection.
Context
Hi everyone,
Last week I spent considerable time investigating our error-handling strategy and OpenAPI description. I initially approached them as separate problems, but I now believe we can solve them through the same initiative.
Gravitino already has useful OpenAPI and Java DTO work to build upon. However, we do not yet treat OpenAPI as the authoritative external contract or continuously verify that the running server conforms to it.
My recommended approach is:
A specification-first V2
V2 should be designed specification-first:
By “V2,” I mean the next trustworthy and reliable version of the Gravitino external API—not OpenAPI Specification 2.0. The V2 contract should use an appropriate current OpenAPI 3.x version and follow established API design practices.
V2 should be a clean external contract. This gives us room to improve:
V1 and V2 can coexist while V2 is developed. We can publish the implemented V2 surface as beta, allowing users to generate clients, build integrations, and give us feedback before the API is declared stable.
OpenAPI should define the external boundary
Our Java DTOs remain useful internal and Java-client models. I am not proposing that we remove them.
I recommend that we stop treating Java DTO shapes as the definition of the external wire protocol.
The OpenAPI contract should independently define:
The server can use a translation layer between the OpenAPI-defined external representations and its internal DTO or domain models.
This allows internal Java code to evolve without automatically changing the public protocol. It also prevents Java-specific types, exception classes, inheritance, and serialization choices from leaking into integrations written in other languages.
Error handling as part of the contract
Error handling is observable API behavior, not merely an implementation detail.
Clients need to distinguish:
V2 should define stable HTTP semantics and a consistent public error model. That model should provide:
Stack traces and internal causes should remain in server logs rather than becoming part of the public protocol.
The error taxonomy defines what failures mean. OpenAPI makes those semantics public and machine-verifiable. Server-side classification preserves the meaning from the catalog adapter to the HTTP response, and conformance testing verifies that the implementation follows the contract.
OpenAPI will therefore become an important pillar of our effort to eliminate undifferentiated HTTP 500 responses.
Why this matters
Adoption and interoperability
Much of the modern data ecosystem is not written in Java. Apache DataFusion, for example, is written in Rust. Other consumers use Python, Go, TypeScript, C++, and languages we may not support directly.
These users cannot easily reuse our Java DTOs. Without a reliable language-neutral contract, every integration must reverse-engineer payloads, maintain handwritten models, or infer behavior from server implementation details.
A code-generation-clean OpenAPI contract allows users to:
This reduces integration friction and expands Gravitino’s potential ecosystem beyond the JVM.
For initial validation, I propose generating Java, Rust, and Python clients. The precise long-term client-support strategy can evolve as we learn from real usage.
Trust through verifiable behavior
A specification alone is a promise. A specification backed by automated conformance, generated-client checks, compatibility analysis, and regression testing provides evidence that the implementation honors that promise.
Users and downstream projects should be able to verify that:
This establishes confidence through measurable behavior rather than documentation alone.
Reliability, security, and maintainability
A stable contract enables:
It also gives contributors a clear target. Server and client development can proceed against an agreed contract, while CI detects drift before it reaches users.
An executable contract
The V2 OpenAPI specification should be part of our testing and release infrastructure, not only a source for rendered documentation.
A practical pipeline can include:
End-to-end tests cover known workflows, but they can exercise only scenarios we write manually. Tools such as Schemathesis can generate valid, invalid, boundary, and adversarial requests directly from OpenAPI.
This lets us test properties such as:
CI can begin in advisory mode while we expose and resolve existing issues. As the specification and server reach conformance, we can progressively make the checks blocking.
Incremental adoption
This should be implemented incrementally, use case by use case.
I propose beginning with catalog and table workflows because they represent central Gravitino behavior and exercise meaningful success, validation, dependency, and error cases.
A practical sequence is:
This approach lets users engage early while allowing the API to grow through concrete, tested use cases.
Future proposal: Antithesis
One future direction I am particularly excited about is integrating Antithesis into the Gravitino testing stack.
A formal V2 contract would give us explicit properties and invariants to test under dependency failures, network faults, concurrency, retries, and unusual operation sequences. Antithesis could exercise the complete system in a deterministic simulation environment and make discovered failures reproducible.
This is not required to begin V2. I intend to develop it as a separate future proposal once the contract and initial conformance infrastructure are established.
Feedback requested from maintainers
I would appreciate feedback on this recommended direction:
If there are viable alternatives to OpenAPI that better serve these goals, I would like to understand and compare them.
References
All reactions