You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Almost all of our guidance on parsing and resolving OADs is under
the section "OpenAPI Description Structure", _except_ for the
parts on resolving relative OAD URI and API URL references.
Those two sections are further down, after a lengthy discussion
of data types.
This moves (without any changes except heading levels) those
URI/URL resolution sections up with all of the other parsing
guidance. I have placed them before the "Implicit Connections"
section because those connections are "Implicit" in contrast
to URI references, which are explicit.
This puts all of the parsing guidance in one place, and properly
contextualizes "Implicit Connections" instead of introducing
them before the far-more-common URI connections.
Copy file name to clipboardExpand all lines: src/oas.md
+57-57Lines changed: 57 additions & 57 deletions
Original file line number
Diff line number
Diff line change
@@ -219,6 +219,63 @@ JSON or YAML objects within an OAD are interpreted as specific Objects (such as
219
219
220
220
If the same JSON/YAML object is parsed multiple times and the respective contexts require it to be parsed as _different_ Object types, the resulting behavior is _implementation defined_, and MAY be treated as an error if detected. An example would be referencing an empty Schema Object under `#/components/schemas` where a Path Item Object is expected, as an empty object is valid for both types. For maximum interoperability, it is RECOMMENDED that OpenAPI Description authors avoid such scenarios.
221
221
222
+
#### Relative References in API Description URIs
223
+
224
+
URIs used as references within an OpenAPI Description, or to external documentation or other supplementary information such as a license, are resolved as _identifiers_, and described by this specification as **_URIs_**.
225
+
As noted under [Parsing Documents](#parsing-documents), this specification inherits JSON Schema Specification Draft 2020-12's requirements for [loading documents](https://www.ietf.org/archive/id/draft-bhutton-json-schema-01.html#section-9) and associating them with their expected URIs, which might not match their current ___location.
226
+
This feature is used both for working in development or test environments without having to change the URIs, and for working within restrictive network configurations or security policies.
227
+
228
+
Note that some URI fields are named `url` for historical reasons, but the descriptive text for those fields uses the correct "URI" terminology.
229
+
230
+
Unless specified otherwise, all fields that are URIs MAY be relative references as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-4.2).
231
+
232
+
##### Establishing the Base URI
233
+
234
+
Relative URI references are resolved using the appropriate base URI, which MUST be determined in accordance with [[RFC3986]][Section 5.1.1 – 5.1.4](https://tools.ietf.org/html/rfc3986#section-5.1.1) and, for Schema objects, [JSON Schema draft 2020-12 Section 8.2](https://www.ietf.org/archive/id/draft-bhutton-json-schema-01.html#section-8.2), as illustrated by the examles in [Appendix G: Examples of Base URI Determination and Reference Resolution](#appendix-g-examples-of-base-uri-determination-and-reference-resolution).
235
+
236
+
If `$self` is a relative URI-reference, it is resolved agains the next possible base URI source ([[RFC3986]][Section 5.1.2 – 5.1.4](https://tools.ietf.org/html/rfc3986#section-5.1.2)) before being used for the resolution of other relative URI-references.
237
+
238
+
The most common base URI source that is used in the event of a missing or relative `$self` (in the [OpenAPI Object](#openapi-object)) and (for [Schema Object](#schema-object)) `$id` is the retrieval URI.
239
+
Implementations MAY support document retrieval, although see the [Security Considerations](#security-considerations) sections for additional guidance.
240
+
Even if retrieval is supported, it may be impossible due to network configuration or server unavailability (including the server hosting an older version while a new version is in development), or undesirable due to performance impacts.
241
+
Therefore, all implementations SHOULD allow users to provide the intended retrieval URI for each document so that references can be resolved as if retrievals were performed.
242
+
243
+
##### Resolving URI fragments
244
+
245
+
If a URI contains a fragment identifier, then the fragment should be resolved per the fragment resolution mechanism of the referenced document. If the representation of the referenced document is JSON or YAML, then the fragment identifier SHOULD be interpreted as a JSON-Pointer as per [RFC6901](https://tools.ietf.org/html/rfc6901).
246
+
247
+
##### Relative URI References in CommonMark Fields
248
+
249
+
Relative references in CommonMark hyperlinks are resolved in their rendered context, which might differ from the context of the API description.
250
+
251
+
#### Relative References in API URLs
252
+
253
+
API endpoints are by definition accessed as locations, and are described by this specification as **_URLs_**.
254
+
255
+
Unless specified otherwise, all fields that are URLs MAY be relative references as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-4.2).
256
+
257
+
Because the API Is a distinct entity from the OpenAPI Document, RFC3986's base URI rules for the OpenAPI Document do not apply.
258
+
Unless specified otherwise, relative references are resolved using the URLs defined in the [Server Object](#server-object) as a Base URL. Note that these themselves MAY be relative to the referring document.
259
+
260
+
##### Examples of API Base URL Determination
261
+
262
+
Assume a retrieval URI of `https://device1.example.com` for the following OpenAPI Document:
263
+
264
+
```YAML
265
+
openapi: 3.2.0
266
+
$self: https://apidescriptions.example.com/foo
267
+
info:
268
+
title: Example API
269
+
version: 1.0
270
+
servers:
271
+
- url: .
272
+
description: The production API on this device
273
+
- url: ./test
274
+
description: The test API on this device
275
+
```
276
+
277
+
For API URLs the `$self` field, which identifies the OpenAPI Document, is ignored and the retrieval URI is used instead. This produces a normalized production URL of `https://device1.example.com`, and a normalized test URL of `https://device1.example.com/test`.
278
+
222
279
#### Resolving Implicit Connections
223
280
224
281
Several features of this specification require resolution of non-URI-based connections to some other part of the OpenAPI Description (OAD).
@@ -333,63 +390,6 @@ Where OpenAPI tooling renders rich text it MUST support, at a minimum, markdown
333
390
While the framing of CommonMark 0.27 as a minimum requirement means that tooling MAY choose to implement extensions on top of it, note that any such extensions are by definition implementation-defined and will not be interoperable.
334
391
OpenAPI Description authors SHOULD consider how text using such extensions will be rendered by tools that offer only the minimum support.
335
392
336
-
### Relative References in API Description URIs
337
-
338
-
URIs used as references within an OpenAPI Description, or to external documentation or other supplementary information such as a license, are resolved as _identifiers_, and described by this specification as **_URIs_**.
339
-
As noted under [Parsing Documents](#parsing-documents), this specification inherits JSON Schema Specification Draft 2020-12's requirements for [loading documents](https://www.ietf.org/archive/id/draft-bhutton-json-schema-01.html#section-9) and associating them with their expected URIs, which might not match their current ___location.
340
-
This feature is used both for working in development or test environments without having to change the URIs, and for working within restrictive network configurations or security policies.
341
-
342
-
Note that some URI fields are named `url` for historical reasons, but the descriptive text for those fields uses the correct "URI" terminology.
343
-
344
-
Unless specified otherwise, all fields that are URIs MAY be relative references as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-4.2).
345
-
346
-
#### Establishing the Base URI
347
-
348
-
Relative URI references are resolved using the appropriate base URI, which MUST be determined in accordance with [[RFC3986]][Section 5.1.1 – 5.1.4](https://tools.ietf.org/html/rfc3986#section-5.1.1) and, for Schema objects, [JSON Schema draft 2020-12 Section 8.2](https://www.ietf.org/archive/id/draft-bhutton-json-schema-01.html#section-8.2), as illustrated by the examles in [Appendix G: Examples of Base URI Determination and Reference Resolution](#appendix-g-examples-of-base-uri-determination-and-reference-resolution).
349
-
350
-
If `$self` is a relative URI-reference, it is resolved agains the next possible base URI source ([[RFC3986]][Section 5.1.2 – 5.1.4](https://tools.ietf.org/html/rfc3986#section-5.1.2)) before being used for the resolution of other relative URI-references.
351
-
352
-
The most common base URI source that is used in the event of a missing or relative `$self` (in the [OpenAPI Object](#openapi-object)) and (for [Schema Object](#schema-object)) `$id` is the retrieval URI.
353
-
Implementations MAY support document retrieval, although see the [Security Considerations](#security-considerations) sections for additional guidance.
354
-
Even if retrieval is supported, it may be impossible due to network configuration or server unavailability (including the server hosting an older version while a new version is in development), or undesirable due to performance impacts.
355
-
Therefore, all implementations SHOULD allow users to provide the intended retrieval URI for each document so that references can be resolved as if retrievals were performed.
356
-
357
-
#### Resolving URI fragments
358
-
359
-
If a URI contains a fragment identifier, then the fragment should be resolved per the fragment resolution mechanism of the referenced document. If the representation of the referenced document is JSON or YAML, then the fragment identifier SHOULD be interpreted as a JSON-Pointer as per [RFC6901](https://tools.ietf.org/html/rfc6901).
360
-
361
-
#### Relative URI References in CommonMark Fields
362
-
363
-
Relative references in CommonMark hyperlinks are resolved in their rendered context, which might differ from the context of the API description.
364
-
365
-
### Relative References in API URLs
366
-
367
-
API endpoints are by definition accessed as locations, and are described by this specification as **_URLs_**.
368
-
369
-
Unless specified otherwise, all fields that are URLs MAY be relative references as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-4.2).
370
-
371
-
Because the API Is a distinct entity from the OpenAPI Document, RFC3986's base URI rules for the OpenAPI Document do not apply.
372
-
Unless specified otherwise, relative references are resolved using the URLs defined in the [Server Object](#server-object) as a Base URL. Note that these themselves MAY be relative to the referring document.
373
-
374
-
#### Examples of API Base URL Determination
375
-
376
-
Assume a retrieval URI of `https://device1.example.com` for the following OpenAPI Document:
377
-
378
-
```YAML
379
-
openapi: 3.2.0
380
-
$self: https://apidescriptions.example.com/foo
381
-
info:
382
-
title: Example API
383
-
version: 1.0
384
-
servers:
385
-
- url: .
386
-
description: The production API on this device
387
-
- url: ./test
388
-
description: The test API on this device
389
-
```
390
-
391
-
For API URLs the `$self` field, which identifies the OpenAPI Document, is ignored and the retrieval URI is used instead. This produces a normalized production URL of `https://device1.example.com`, and a normalized test URL of `https://device1.example.com/test`.
392
-
393
393
### Schema
394
394
395
395
This section describes the structure of the OpenAPI Description format.
0 commit comments