Skip to content

Commit

Permalink
feat: add initial versioning endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Sporiff committed Aug 27, 2023
1 parent 22ad3f9 commit 8e442fc
Show file tree
Hide file tree
Showing 7 changed files with 332 additions and 14 deletions.
36 changes: 22 additions & 14 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default defineConfig({
integrations: [
AutoImport({
imports: [
{ "@astrojs/starlight/components": ["Card", "CardGrid", "LinkCard", "Tabs", "TabItem"] }
{ "@astrojs/starlight/components": ["Card", "CardGrid", "LinkCard", "Tabs", "TabItem"] },
]
}),
starlight({
Expand All @@ -24,19 +24,27 @@ export default defineConfig({
label: "Project overview",
link: "overview"
}, {
label: "Specifications",
items: [
{
label: "Introduction",
link: "specs"
},
{
label: "Subscriptions",
collapsed: true,
autogenerate: {
directory: "specs/subscriptions"
}
}]
label: "Specifications",
items: [
{
label: "Introduction",
link: "specs"
},
{
label: "Subscriptions",
collapsed: true,
autogenerate: {
directory: "specs/subscriptions"
}
},
{
label: "Versioning",
collapsed: true,
autogenerate: {
directory: "specs/versioning"
}
}
]
},
{
label: "API explorer",
Expand Down
Binary file added public/opapi-logo_36x36.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions public/openpodcast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ info:
tags:
- name: Subscriptions
description: All actions relating to subscription management
- name: Versions
description: All actions relating to supported versions and capabilities
paths:
/subscriptions:
get:
Expand Down Expand Up @@ -202,6 +204,65 @@ paths:
security:
- podcast_auth:
- read:subscriptions
/versions:
get:
tags:
- Versions
summary: Retrieve a list of supported versions
description: Retrieve a list of each supported major/minor version of the API from the server
operationId: getVersions
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/VersionArray'
application/xml:
schema:
$ref: '#/components/schemas/VersionArray'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
security:
- podcast_auth:
- read:versions
/{major_version}/capabilities:
get:
tags:
- Versions
summary: Retrieve a list of supported capabilities
description: Retrieve a list of each supported capabilties from the server
operationId: getCapabilities
parameters:
- in: path
name: major_version
schema:
type: string
required: true
examples:
v1:
value: 'v1'
v2:
value: 'v2'
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Capabilities'
application/xml:
schema:
$ref: '#/components/schemas/Capabilities'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
security:
- podcast_auth:
- read:versions
components:
responses:
Unauthorized:
Expand Down Expand Up @@ -573,6 +634,37 @@ components:
deletion_id: 25
status: SUCCESS
message: Subscription deleted successfully
VersionArray:
type: object
xml:
name: versions
properties:
versions:
type: array
items:
xml:
name: version
type: string
description: "The supported version numbers"
example:
- "v1.1"
- "v2.0"
Capabilities:
type: object
xml:
name: root
properties:
capabilities:
type: object
additionalProperties:
type: object
example:
queue_sync:
max_queues: 5
store_shows: {}
store_episodes:
allow: true
upload_quota: 500
requestBodies:
FeedArray:
description: An array of feeds the user wants to subscribe to
Expand Down Expand Up @@ -601,6 +693,8 @@ components:
scopes:
write:subscriptions: modify subscription information for your account
read:subscriptions: read your subscription information
read:versions: read supported server versions
read:capabilities: read supported server capabilities
api_key:
type: apiKey
name: api_key
Expand Down
9 changes: 9 additions & 0 deletions public/rapidoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@
use-path-in-nav-bar="true"
allow-spec-url-load="false"
allow-spec-file-load="false"
primary-color="#b3c7ff"
bg-color="#17181c"
text-color="#c0c2c7"
font-size="large"
show-curl-before-try="true"
>
<img
slot="logo"
src="/opapi-logo_36x36.png"
/>
</rapi-doc>
</body>
</html>
96 changes: 96 additions & 0 deletions src/content/docs/specs/versioning/get-capabilities.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
title: Get supported capabilities
description: Query a server for its supported capabilities
sidebar:
order: 3
---

import CoreAction from "@partials/_core-action.mdx";

<CoreAction />

```
GET /{major_version}/capabilities
```

This endpoint informs clients of all capabilities supported by the server. This information MUST inform the client of any supported **optional** features as well as any configuration options associated with them.

Each capability is returned as an **object** containing key-value pairs representing the capability's settings. Clients SHOULD use this information to adjust their behavior.

## Parameters

| Field | Type | In | Required? | Description |
| --------------- | ------ | ---- | --------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `major_version` | String | Path | Yes | The **major** version that the client wants to target. <br /> The server MUST return all supported features for **each** major version. |

## Client behavior

Clients SHOULD inform the user which features are supported by the server. Clients MAY also display information about relevant settings.

## Server behavior

The server MUST respond with all supported **optional** features and any associated settings. If a feature isn't enabled, the server MUST NOT include it in the response.

## Example request

<Tabs>
<TabItem label="JSON">

```console
$ curl -X 'GET' \
'/v1/capabilities' \
-H 'accept: application/json'
```

</TabItem>
<TabItem label="XML">

```console
$ curl -X 'GET' \
'/v1/capabilities' \
-H 'accept: application/xml'
```

</TabItem>
</Tabs>

<Tabs>
<TabItem label="JSON">

```json
{
"capabilities": {
"queue_sync": {
"max_queues": 5
},
"store_shows": {},
"store_episodes": {
"allow": true,
"upload_quota": 500
}
}
}
```

</TabItem>
<TabItem label="XML">

```xml
<?xml version="1.0" encoding="UTF-8"?>
<root>
<capabilities>
<queue_sync>
<max_queues>5</max_queues>
</queue_sync>
<store_shows>
</store_shows>
<store_episodes>
<allow>true</allow>
<upload_quota>500</upload_quota>
</store_episodes>
</capabilities>
</root>
```

</TabItem>
</Tabs>
86 changes: 86 additions & 0 deletions src/content/docs/specs/versioning/get-versions.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
title: Get supported versions
description: Query a server for its supported versions
sidebar:
order: 2
---

import CoreAction from "@partials/_core-action.mdx";

<CoreAction />

```
GET /versions
```

This endpoint returns an array of versions supported by the server. This informs the client what **core** features are supported. The array MUST contain an entry for each **major** version supported by the server.

Versions follow the following format:

```
v{major_version}.{minor_version}
```

:::note
The `minor_version` MUST reflect the **highest** minor version supported by the server.
:::

| Field | Type | Required? | Description |
| ---------- | --------------- | --------- | ---------------------------- |
| `versions` | Array\<String\> | Yes | A list of supported versions |

## Client behavior

Clients SHOULD use the version number to adjust their behavior. For example, if the client is built with support for **v1.4** of the spec, and the server supports up to **v1.2**, the client should modify its calls to ensure they are compatible with **v1.2**.

## Server behavior

Servers MUST respond with all fields, including deprecated fields, to ensure that older clients can interpret the response properly.

## Example request

<Tabs>
<TabItem label="JSON">

```console
$ curl -X 'GET' \
'/versions' \
-H 'accept: application/json'
```

</TabItem>
<TabItem label="XML">

```console
$ curl -X 'GET' \
'/versions' \
-H 'accept: application/xml'
```

</TabItem>
</Tabs>

<Tabs>
<TabItem label="JSON">

```json
[
"v1.1",
"v2.0"
]
```

</TabItem>
<TabItem label="XML">

```xml
<?xml version="1.0" encoding="UTF-8"?>
<versions>
<version>v1.1</version>
<version>v2.0</version>
</versions>
```

</TabItem>

</Tabs>
25 changes: 25 additions & 0 deletions src/content/docs/specs/versioning/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: API versioning
description: Details about how the API is versioned
prev: false
sidebar:
label: Versioning
order: 1
---

The Open Podcast API is subject to change over time. To ensure backwards compatibility and effective communication of server capabilities, the API specification MUST be versioned in a consistent way.

The specification follows the [Semantic versioning model](https://semver.org/). Each version of the specification MUST adhere to the following rules:

**Major** versions
: A major version update indicates that a breaking change has occured. This is reserved for the deprecation, addition, or renaming of **core** capabilities.

**Minor** versions
: A minor version update indicates that a new **optional** feature has been added or that a **core** feature has received a non-breaking change. This can include the deprecation or addition of parameters or behaviors.

**Patch** versions
: A patch version update indicates that a small non-breaking change has been made to clarify a feature or address an issue with wording.

## Backwards compatibility

To maintain backwards compatibility between **minor** versions, no parameters nor endpoints may be removed without a **major** version change. Fields may be deprecated in favor of new behaviors, but when queried by an older client the server MUST respond with a compatible response.

0 comments on commit 8e442fc

Please sign in to comment.