Rename referenceObject / $ref property #49
Replies: 3 comments 2 replies
-
|
I do not have an opinion on the proposal of how we move on from |
Beta Was this translation helpful? Give feedback.
-
|
Yes! This is definitely the right time to think about make a change here. I believe there is a significant opportunity for both simplification and increasing the semantics we represent.
If we do this, we can a) avoid the need for the ugly syntax with URLs b) prevent people from referencing incompatible types c) make a clean separation between importing concepts from external documents vs doing internal referencing. The more I think about these things, the more questions I have. I'm just going to try and list the confusion in my head at the moment:
|
Beta Was this translation helpful? Give feedback.
-
|
This topic was discussed extensively in the 20 July 2023 OpenAPI call (see OAI/OpenAPI-Specification#3326 for the agenda and pre-meeting discussion). My recollection (almost two weeks later) is that:
Regarding location vs identity: (note: I'll use URI and URL because "IRL" is not a thing) The analogy here is importing modules in a programming language. You import by the module name (its identity - URI), which in some languages has a hierarchical structure and in others does not (or only has a limited one, e.g. NPM "@"-namespaces). The compiler or runtime environment then consults its configuration to find the actual file to load (the location - URL). We can further extend this analogy by considering package managers, which most major languages have these days. In Python, if I want to use the popular Identifier (URI-analog):
Locations (all of which can be expressed as URLs):
why should you care?Back in the old days... (ahem)... installing and using a library was a lot more of a pain. You had to go get the package yourself, and know where to put it. You had to set environment variables or pass command-line flags to the compiler or interpreter. This is where we are right now with Look above where the local file is Also, consider if you had to download the package every time you ran a program - not only would performance be horrible, a restrictive firewall (or an air-gapped network) would make it impossible. I've worked at companies that configured internal package manager servers for these reasons. Plus, sometimes you want to install a development version, which is why all of these scenarios apply just as much to working with OAS as working with code As far as my assertion that OAS documents should declare their own URI/IRI, note that But let's do realize that this is analogous to programming languages, and the software fields has decades of experience learning what is needed for proper tooling with good UX. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
From the README and https://github.com/OAI/moonwalk/blob/bd4e2ac3edef2226ae54c22c88d4d90f3de1079f/examples/aggregatedapi.yaml#L6
Now might be the time to consider properly divorcing our
referenceObjectfrom JSON Schema's$refkeyword:schemais problematic enough, if we go back to subset/superset/sideset we push more pain on to our consumers$refs inschemaObjects,referenceObjectsandpathItemObjectsleading to incorrect behaviour$refkeywords or allowingallOfin thereferenceObjecthave been proposed before for composing thepathsobject$refproperty/field in thepathItemobject which has more undefined than defined behaviours$refcurrently supports URIs, but we lack$id/$anchorproperties in ourreferenceObjectso we limit JSON Schema compatibility. Is there actually a case for using URIs to compose OAS documents (rather than relative references or absolute URLs)? If we changed this, we would have to specify that$refURLs were relative to the referring document, not theservers.url(that they are design-time not run-time URLs)referenceObjectonly allows processing ofdescriptionandsummaryproperties, it might be helpful to formally document which properties/fields in OAS are annotations/metadata and which are "concrete" data, and allow all annotationscomponentsobject, indicating that we are importing from a library of components which just happens to be held within the same OAS documentexampleObjectexternalValueUR[I|L]s should always or optionally be fetched to bundle a complete OAS documentI would propose a
use,@use,importor@importkeyword in a renamedimportObject, which for simplicity could always be an array. If we allow variant object and array forms, we should follow the same pattern forexternalDocsfor consistency. The object form would always behave in the same manner as a 1-element array.Beta Was this translation helpful? Give feedback.
All reactions