-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Draft proposal for experimental field #2386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
1072487
add proposal file from template
davidjgoss 2f19329
start to flesh out
davidjgoss 36427e4
try that table again
davidjgoss 201616c
a bit more
davidjgoss 83c9c46
getting there
davidjgoss b03e1b6
add example yaml
davidjgoss 245e9f4
prior art referencing typescript libs
davidjgoss 994fd3a
quote from api-extractor
davidjgoss bec991a
rename and updates
davidjgoss 584710e
mention stubs
davidjgoss 8951862
add to parameter
davidjgoss d636c86
recast as being about `required`
davidjgoss f825f3f
discuss overlays as an alternative
davidjgoss 3bda71e
Merge branch 'OAI:main' into proposal-beta
davidjgoss 4587338
Update and rename 005_Experimental.md to 2020-10-28-Experimental.md
davidjgoss 932dcc7
Merge branch 'master' into proposal-beta
davidjgoss 7ce2ecf
express default value as boolean
davidjgoss 4f42b06
clarify relationship with deprecated
davidjgoss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# Experimental marker | ||
|
||
## Metadata | ||
|
||
|Tag |Value | | ||
|---- | ---------------- | | ||
|Proposal |[005_Experimental](https://github.com/OAI/OpenAPI-Specification/tree/master/proposals/005_Experimental.md)| | ||
|Authors|[David Goss](https://github.com/davidjgoss)| | ||
|Review Manager |TBD | | ||
|Status |Proposal| | ||
|Implementations || | ||
|Issues || | ||
|Previous Revisions || | ||
|
||
## Change Log | ||
|
||
|Date |Responsible Party |Description | | ||
|---- | ---------------- | ---------- | | ||
|
||
## Introduction | ||
|
||
A way to mark an aspect of the API as "experimental", indicating that it is not yet a fully stable and supported part of the API. | ||
|
||
## Motivation | ||
|
||
Consider an API with two categories of thing in it: | ||
|
||
- Core, stable things, where we are committed to the ongoing stability and have no intention of making breaking changes. | ||
- New, experimental things, where we are getting them out there for feedback and early adopters, but they may change before we consider them to be in the first category, or even just get removed. | ||
|
||
These sit together fine in principle, but cause friction when trying to apply something like semver to the API as a whole. How do we make changes to the experimental stuff - without bumping the major version several times a year and scaring consumers - while also ensuring we can't make breaking changes to the core stuff we never _want_ to break. | ||
|
||
## Proposed solution | ||
|
||
Add an "experimental" field which specifies that an items in the API is not yet fully stable and supported, may change or be removed without a major version bump, and as such should be used with caution. | ||
|
||
_(I don't have a strong opinion about the naming - "beta" is another idea, though I think "experimental" does the job better in terms of being the most noncommital.)_ | ||
|
||
Downstream tools could then make use of this metadata: | ||
|
||
- Tools like swagger-ui could surface this in the documentation they generate so consumers are made aware. Experimental items could also be filtered out of the documentation if desired. | ||
- Tools for detecting and preventing breaking changes could take this into consideration when deciding whether a change is breaking. | ||
|
||
## Detailed design | ||
|
||
A new boolean field named `experimental`, defaulting to `experimental`, is added to: | ||
|
||
- Operation | ||
- Schema | ||
|
||
This specifies that the operation or schema is not yet stable and SHOULD be used with caution. | ||
|
||
### Operation Object | ||
|
||
... | ||
|
||
##### Fixed Fields | ||
|
||
Field Name | Type | Description | ||
---|:---:|--- | ||
... | ... | ... | ||
<a name="operationExperimental"></a>experimental | `boolean` | Specifies that an operation is in experimental status, meaning it may change outside of the normal breaking change process. Consumers SHOULD use with caution. Default value is `false`. | ||
|
||
### Schema Object | ||
|
||
... | ||
|
||
##### Fixed Fields | ||
|
||
Field Name | Type | Description | ||
---|:---:|--- | ||
... | ... | ... | ||
<a name="schemaExperimental"></a>experimental | `boolean` | Specifies that a schema is in experimental status, meaning it may change outside of the normal breaking change process. Consumers SHOULD use with caution. Default value is `false`. | ||
|
||
### Example Spec | ||
|
||
```yaml | ||
/asset/constraints: | ||
get: | ||
tags: | ||
- Asset | ||
- Constraints | ||
summary: Get a set of asset constraints | ||
operationId: constraints | ||
parameters: | ||
- name: siteToken | ||
in: query | ||
description: Site token obtained from Site API | ||
required: true | ||
schema: | ||
type: string | ||
experimental: true | ||
``` | ||
### Prior Art | ||
|
||
This kind of requirement is handled for TypeScript libraries by [api-extractor](https://api-extractor.com/pages/tsdoc/doc_comment_syntax/#release-tags) - they have both "alpha" and "beta" markers with a somewhat opinionated flow attached - I'm not sure that level of granularity is necessary. But the "beta" and "public" ones map well to the motivations described here: | ||
|
||
> - **beta**: Indicates that an API item has been released as a preview or for experimental purposes. Third parties are encouraged to try it and provide feedback. However, a “beta” API should NOT be used in production, because it may be changed or removed in a future version. | ||
> - **public**: Indicates that an API item has been officially released, and is now part of the supported contract for a package. If the SemVer versioning scheme is used, then the API signature cannot be changed without a MAJOR version increment. | ||
|
||
### Unanswered Questions | ||
|
||
- If an operation is not marked as experimental, but it is using a schema which is (i.e. as its request object), then it is implicitly also unstable. Would this usage be considered invalid? | ||
- Should `experimental` and `deprecated` be mutually exclusive? | ||
|
||
## Backwards compatibility | ||
|
||
The `experimental` field would default to false, meaning existing behaviour is preserved, and the new field is only used on an opt-in basis. | ||
|
||
## Alternatives considered | ||
|
||
- _Specification extensions_ - publishers could add an extension in their own domain, but the benefit of the metadata being available to downstream tools (including those used by consumers, not just publishers) would be lost. | ||
- _Tags_ - as above, but this also gets to mixing other kinds of metadata in with resource taxonomy, which seems wrong. | ||
- _Different API_ - this would be the least messy from a technical perspective - maintain a completely separate API for experimental items, and then "promote" them to the main API once they are considered stable. This has increased overhead for publishers and consumers, and could also reduce the likelihood of getting feedback on, and early uptake of, experimental items if they are segregated in a different place altogether. | ||
|
||
lornajane marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether adding the
experimental
field to higher level objects (such asparameter
,requestBody
andresponse
) and dropping it fromschema
would work better? It might resolve the 'unanswered question' about experimental schema use in non-experimental operations.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd missed parameter - have added that now, with a qualifier that it couldn't be used
withwithin: path
required: true
since adding a new required parameter is a breaking change.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point about
schema
, I agree removing it from there would simplify. I'm not sure I understand how putting onrequestBody
andresponse
instead would alleviate though, could you elaborate?One use case I've had come up is having a subset of an object be experimental, like "we've added some more detail to this response, we're not totally sure about it yet but the rest of it remains stable in the meantime", so it would be a shame not to cover that, but perhaps a leaner way to introduce the concept initially?