Skip to content

Commit d7ef997

Browse files
committed
First pass at explaining SAFs
1 parent 51aaf58 commit d7ef997

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

src/oas.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ At this time, such elements are expected to remain part of the OAS until the nex
2828

2929
Occasionally, non-backwards compatible changes may be made in `minor` versions of the OAS where impact is believed to be low relative to the benefit provided.
3030

31+
### Standardized API Features
32+
33+
Many API features have behavior that is difficult or impossible to infer from
34+
descriptions of paths, parameters, headers, or other operation elements that
35+
this specification supports.
36+
37+
We refer to such features that are standardized by other standards bodies
38+
as Standardized API Features, or SAFs. These features benefit from special
39+
handling, such as how the `Authorization` header is managed through the
40+
Security Scheme Object rather than the Parameter Object. Security features
41+
also illustrate another aspect of SAFs, which is that they often evolve
42+
at a more rapid pace than the core of HTTP.
43+
44+
To better support security features and expand into other SAFs, the OpenAPI
45+
Initiative is introducing companion specifications grouping independently
46+
versioned SAFs. These specifications describe opt-in rules that establish
47+
SAF-specific Objects as well as exception rules such as those regarding
48+
the `Authorization` header and Security Schemes.
49+
3150
### Undefined and Implementation-Defined Behavior
3251

3352
This specification deems certain situations to have either _undefined_ or _implementation-defined_ behavior.
@@ -95,6 +114,7 @@ In addition to the required fields, at least one of the `components`, `paths`, o
95114
| Field Name | Type | Description |
96115
| ---- | :----: | ---- |
97116
| <a name="oas-version"></a>openapi | `string` | **REQUIRED**. This string MUST be the [version number](#versions-and-deprecation) of the OpenAPI Specification that the OpenAPI document uses. The `openapi` field SHOULD be used by tooling to interpret the OpenAPI document. This is _not_ related to the [`info.version`](#info-version) string, which describes the OpenAPI document's version. |
117+
| <a name="using-features"></a>usingFeatures | Map[`string, `string`] | A map of [SAF](#standardized-api-features) names, as defined in various companion specifications, to a valid version string for the named SAF. Implementations MUST apply the SAF's rules, such as treating header parameters that are managed by the SAF as illegal in Parameter Objects, while processing the current document. The default is `{"legacySecurity": "3.3.0"}`. |
98118
| <a name="oas-self"></a>$self | `string` | This string MUST be in the form of a URI reference as defined by [[RFC3986]] [Section 4.1](https://www.rfc-editor.org/rfc/rfc3986#section-4.1). The `$self` field provides the self-assigned URI of this document, which also serves as its base URI in accordance with [[RFC3986]] [Section 5.1.1](https://www.rfc-editor.org/rfc/rfc3986#section-5.1.1). Implementations MUST support identifying the targets of [API description URIs](#relative-references-in-api-description-uris) using the URI defined by this field when it is present. See [Establishing the Base URI](#establishing-the-base-uri) for the base URI behavior when `$self` is absent or relative, and see [Appendix F](#appendix-f-examples-of-base-uri-determination-and-reference-resolution) for examples of using `$self` to resolve references. |
99119
| <a name="oas-info"></a>info | [Info Object](#info-object) | **REQUIRED**. Provides metadata about the API. The metadata MAY be used by tooling as required. |
100120
| <a name="oas-json-schema-dialect"></a> jsonSchemaDialect | `string` | The default value for the `$schema` keyword within [Schema Objects](#schema-object) contained within this OAS document. This MUST be in the form of a URI. See [JSON Schema Keywords](#json-schema-keywords) to determine the default value. |
@@ -127,6 +147,25 @@ It is RECOMMENDED that the entry document of an OAD be named `openapi.json` or `
127147
An OpenAPI Object MAY be embedded in another format, called the **embedding format**, just as JSON Schema is embedded in the OAS in the form of Schema Objects.
128148
It is the responsibility of an embedding format to define how to parse embedded content, and OAS implementations that do not document support for an embedding format cannot be expected to parse embedded OAS content correctly.
129149

150+
##### OpenAPI and SAF Versions Across Multiple Documents
151+
152+
The `openapi` and `usingFeatures` fields define how the document that contains
153+
them is to be parsed. When using multiple documents in an OAD, interoperability
154+
is only guaranteed if the SAFs in `usingFeatures` are the same in all
155+
documents, and the major and minor version numbers for `openapi` and each
156+
SAF in `usingFeatures` match.
157+
158+
Implementations MUST raise an error if different SAFs are included in
159+
different documents within the OAD, and SHOULD raise an error if any
160+
SAF or `openapi` version in a referenced document is not compatible
161+
with the corresponding version in the entry document. Implementations
162+
MAY raise an error if the major and minor versions are compatible but
163+
not the same; otherise the behavior is implementation-defined.
164+
165+
Only the major and minor version numbers determine compatibility.
166+
However, note that while OAS v3.1 is compatible with v3.2, which is compatible
167+
with v3.3, OAS 3.0 is not compatible with any other version.
168+
130169
##### Parsing Documents
131170

132171
Each document in an OAD MUST be fully parsed in order to locate possible reference targets.

src/schemas/validation/schema.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ properties:
88
openapi:
99
type: string
1010
pattern: '^3\.3\.\d+(-.+)?$'
11+
usingFeatures:
12+
type: object
13+
additionalProperties:
14+
type: string
15+
pattern: '^\d\.\d\.\d'
16+
default:
17+
legacySecurity: '3.3.0'
1118
$self:
1219
type: string
1320
format: uri-reference

tests/schema/pass/info-object-example.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# including External Documentation Object Example
22
openapi: 3.3.0
3+
usingFeatures:
4+
legacySecurity: 3.3.0
35
$self: https://example.com/openapi
46
info:
57
title: Example Pet Store App

0 commit comments

Comments
 (0)