Proposal: a consumer-optimized form of OpenAPI descriptions #63
Replies: 3 comments 2 replies
-
I'm unclear if this solves an existing problem. How can an OpenAPI description ever not meet the criteria of having resolvable references and being useful to consumers? Already it's common practice to validate, or even dereference, OpenAPI descriptions during an API workflow, could you say a bit more about where you see problems and how this helps? (sorry, I think I just don't understand) |
Beta Was this translation helpful? Give feedback.
-
@earth2marsh I agree (I think) that there's a need for a way to package up a complete OAD for easy transfer, deployment, and processing. I also think that the combination of Darrel's imports syntax and the additional requirements I added around import resolution and loading changes the calculus here, particularly when you include ways to fence in JSON Schema's In 3.x, there are a lot of complex steps to implement, and ambiguities to resolve, to support referencing. In Moonwalk, the imports process is just:
Steps 1, 2, 5, and 6 are trivial. The imports proposal (#72) is structured to allow steps 3 and 4 to be handled outside of OAS implementations, with the results provided to implementations in an interoperable way. Steps 3 and 4 can involve a lot of complexity, and I think you are right to try to eliminate it. A single-document package format would make steps 3 and 4 trivial for tools that understand that format. There are a few things that I think we want to avoid here:
A simple size-and-line-number-preserving packaging solution would be to take inspiration from JSON Text Sequences (
Processing this and building the namespace and component index would be very fast. Step 3 becomes trivial because the only valid location is within the document sequence. Step 4 is trivial because you are already parsing the document stream and therefore something already retrieved it. Documents that do not have a Now let's take JSON Schema into account. We can include JSON Schema documents in the stream (either by putting then at the end or ensuring there's a way to distinguish document types while parsing the stream) with the following constraints:
This could be futher condensed by requiring that all JSON Schema documents be packaged as a single bundled document. This does not eliminate the complexity of handling JSON Schema references, but (combined with the fencing techniques suggested in #73) does reduce it to the existing problem handled by all compliant JSON Schema tools. I think this sort of document sequence format would accomplish the key goals while adding a very small amount of format-specific work. Also, nothing prevents tools from doing whatever other processing they want with documents before putting them in a sequence. If it makes sense to inline reference targets, they can do that (and even have a sequence of one document for consistency). But inlining isn't always possible and is a trade-off rather than always being an optimization. it can consume a lot of space, and loses information in the form of persistent component identifiers. And with standards groups publishing component shapes for use across many APIs, use cases for preserving identifiers are becoming more significant. |
Beta Was this translation helpful? Give feedback.
-
See also (closed in favor of continuing the discussion here): |
Beta Was this translation helpful? Give feedback.
-
TL;DR Introduces the concept that publishing an OpenAPI document for consumer-use means resolving any remote references.
An OpenAPI description can be spread across multiple files using JSON Pointers. This is particularly useful for authoring, such as when different people are responsible for different parts of the description.
But in order for that description to be used in practice, all of those references need to be resolved. This is true whether it is being used to rendering documentation for humans, validating the well-formedness of requests at runtime, or generating an SDK.
Implications:
Beta Was this translation helpful? Give feedback.
All reactions