Skip to content

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 18 commits into from
Apr 28, 2024
Merged
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions proposals/005_Experimental.md
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
Copy link
Member

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 as parameter, requestBody and response) and dropping it from schema would work better? It might resolve the 'unanswered question' about experimental schema use in non-experimental operations.

Copy link
Contributor Author

@davidjgoss davidjgoss Dec 9, 2020

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 with in: path with required: true since adding a new required parameter is a breaking change.

Copy link
Contributor Author

@davidjgoss davidjgoss Dec 9, 2020

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 on requestBody and response 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?


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.