Skip to content
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

Migrate API server specification from Swagger 2.0 to OpenAPI 3.1 #4763

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ and this project adheres to

### Changed

- [#4763](https://github.com/firecracker-microvm/firecracker/pull/4763):
Migrated API specification from Swagger 2.0 to OpenAPI 3.1.

### Deprecated

### Removed
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ Firecracker's overall architecture is described in

Firecracker consists of a single micro Virtual Machine Manager process that
exposes an API endpoint to the host once started. The API is
[specified in OpenAPI format](src/firecracker/swagger/firecracker.yaml). Read
more about it in the [API docs](docs/api_requests).
[specified in OpenAPI 3.1 format](src/firecracker/openapi/firecracker.yaml).
Read more about it in the [API docs](docs/api_requests).

The **API endpoint** can be used to:

Expand Down
2 changes: 1 addition & 1 deletion SPECIFICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on the following:
they are logged[^2] by the Firecracker process.
1. **API Stability:** The API socket is always available and the API conforms to
the in-tree
[Open API specification](src/firecracker/swagger/firecracker.yaml). API
[Open API specification](src/firecracker/openapi/firecracker.yaml). API
failures are logged in the Firecracker log.
1. **Overhead:** For a Firecracker virtual machine manager running a microVM
with `1 CPUs and 128 MiB of RAM`, and a guest OS with the Firecracker-tuned
Expand Down
20 changes: 10 additions & 10 deletions docs/api-change-runbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,19 @@ conditions, there are 2 major cases where we need to deprecate an endpoint:
but doing so immediately would be a breaking change.
- We just mark the endpoint as deprecated.

### Keeping Swagger updated
### Keeping OpenAPI specification updated

Make sure that any changes you make in the code are also reflected in the
swagger specification.
OpenAPI specification.

Some tips:

- There is nothing in the swagger file that shows whether an endpoint is
- There is nothing in the OpenAPI file that shows whether an endpoint is
mandatory or optional, it’s all code logic.
- Mandatory fields in a request or response body are marked with
`required: true` in the swagger definition. All other fields are optional.
- Mandatory fields in a request or response body are marked with the `required`
array. All other fields are optional.
- If you need to redirect an endpoint, you have to clone the old one under the
new URI in the swagger specification.
new URI in the OpenAPI specification.

### Marking endpoints as deprecated

Expand Down Expand Up @@ -234,10 +234,10 @@ Firecracker API.
deprecation case.
- Add a unit test where you test your new code paths.
- Fix all other failing unit tests.
- Update the swagger file to reflect the change, in this case by removing the
`vsock_id` field from the required parameter list in the `Vsock` definition
and adding a description to it stating that it is deprecated since the
current version.
- Update the OpenAPI specification to reflect the change, in this case by
removing the `vsock_id` field from the required parameter list in the
`Vsock` definition and adding a description to it stating that it is
deprecated since the current version.
- Update any relevant documentation.
- We update the python integration tests to reflect the change (reference
implementation in [this commit][4]).
Expand Down
2 changes: 1 addition & 1 deletion docs/api_requests/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Firecracker microVMs can execute actions that can be triggered via `PUT`
requests on the `/actions` resource.

Details about the required fields can be found in the
[swagger definition](../../src/firecracker/swagger/firecracker.yaml).
[OpenAPI specification](../../src/firecracker/openapi/firecracker.yaml).

## InstanceStart

Expand Down
2 changes: 1 addition & 1 deletion docs/api_requests/patch-network-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Accept: application/json
```

The full specification of the data structures available for this call can be
found in our [OpenAPI spec](../../src/firecracker/swagger/firecracker.yaml).
found in our [OpenAPI spec](../../src/firecracker/openapi/firecracker.yaml).

**Note**: The data provided for the update is merged with the existing data. In
the above example, the RX rate limit is updated, but the TX rate limit remains
Expand Down
14 changes: 7 additions & 7 deletions docs/device-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ BadRequest - HTTP response.

## Input Schema

All input schema fields can be found in the [Swagger](https://swagger.io)
All input schema fields can be found in the [OpenAPI](https://www.openapis.org/)
specification:
[firecracker.yaml](./../src/firecracker/swagger/firecracker.yaml).
[firecracker.yaml](./../src/firecracker/openapi/firecracker.yaml).

| Schema | Property | keyboard | serial console | virtio-block | vhost-user-block | virtio-net | virtio-vsock | virtio-rng |
| ------------------------- | --------------------- | :------: | :------------: | :----------: | :--------------: | :--------: | :----------: | :--------: |
Expand Down Expand Up @@ -108,9 +108,9 @@ virtio-block and virtio-rng devices.

## Output Schema

All output schema fields can be found in the [Swagger](https://swagger.io)
specification:
[firecracker.yaml](./../src/firecracker/swagger/firecracker.yaml).
All output schema fields can be found in the
[OpenAPI](https://www.openapis.org/) specification:
[firecracker.yaml](./../src/firecracker/openapi/firecracker.yaml).

| Schema | Property | keyboard | serial console | virtio-block | vhost-user-block | virtio-net | virtio-vsock |
| ---------------------- | ----------------- | :------: | :------------: | :----------: | :--------------: | :--------: | :----------: |
Expand All @@ -133,9 +133,9 @@ If more than 64 devices are configured for a VM in total on aarch64, only first

## Instance Actions

All instance actions can be found in the [Swagger](https://swagger.io)
All instance actions can be found in the [OpenAPI](https://www.openapis.org/)
specification:
[firecracker.yaml](./../src/firecracker/swagger/firecracker.yaml).
[firecracker.yaml](./../src/firecracker/openapi/firecracker.yaml).

| Action | keyboard | serial console | virtio-block | vhost-user-block | virtio-net | virtio-vsock |
| ---------------- | :------: | :------------: | :----------: | :--------------: | :--------: | :----------: |
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ configuration for the guest kernel and rootfs, all of the other resources are
optional. This configuration method will also start the microVM, as such you
need to specify all desired pre-boot configurable resources in the JSON. The
names of the resources can be seen in \[`firecracker.yaml`\]
(../src/firecracker/swagger/firecracker.yaml) and the names of their fields are
(../src/firecracker/openapi/firecracker.yaml) and the names of their fields are
the same that are used in the API requests.

An example of configuration file is provided:
Expand Down
2 changes: 1 addition & 1 deletion docs/logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ curl --unix-socket /tmp/firecracker.socket -i \
```

Details about the required and optional fields can be found in the
[swagger definition](../src/firecracker/swagger/firecracker.yaml).
[OpenAPI specification](../src/firecracker/openapi/firecracker.yaml).

## Using command line parameters for configuration

Expand Down
2 changes: 1 addition & 1 deletion docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ curl --unix-socket /tmp/firecracker.socket -i \
```

Details about this configuration can be found in the
[swagger definition](../src/firecracker/swagger/firecracker.yaml).
[OpenAPI specification](../src/firecracker/openapi/firecracker.yaml).

The metrics are written to the `metrics_path` in JSON format.

Expand Down
2 changes: 1 addition & 1 deletion docs/mmds/mmds-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ reply.

Somewhat confusingly, this is the name of the component which taps the device
model. It has a user-configured IPv4 address (see
[Firecracker MMDS configuration API](../../src/firecracker/swagger/firecracker.yaml))
[Firecracker MMDS configuration API](../../src/firecracker/openapi/firecracker.yaml))
and MAC (`06:01:23:45:67:01`) addresses. The latter is also used to respond to
ARP requests. For every frame coming from the guest, the following steps take
place:
Expand Down
10 changes: 5 additions & 5 deletions docs/mmds/mmds-user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ two steps:
1. Attach one (or more) network interfaces through an HTTP `PUT` request to
`/network-interfaces/${MMDS_NET_IF}`. The full network configuration API can
be found in the
[firecracker swagger file](../../src/firecracker/swagger/firecracker.yaml).
[Firecracker OpenAPI specification](../../src/firecracker/openapi/firecracker.yaml).
1. Configure MMDS through an HTTP `PUT` request to `/mmds/config` resource and
include the IDs of the network interfaces that should allow forwarding
requests to MMDS in the `network_interfaces` list. The complete MMDS API is
described in the
[firecracker swagger file](../../src/firecracker/swagger/firecracker.yaml).
[Firecracker OpenAPI specification](../../src/firecracker/openapi/firecracker.yaml).

### Examples

Expand Down Expand Up @@ -115,7 +115,7 @@ structured in [JSON](https://tools.ietf.org/html/rfc7159) format. To replace
existing metadata, a subsequent HTTP `PUT` request to the `/mmds` resource must
be issued, using as a payload the new metadata. A complete description of
metadata insertion firecracker API can be found in the
[firecracker swagger file](../../src/firecracker/swagger/firecracker.yaml).
[Firecracker OpenAPI specification](../../src/firecracker/openapi/firecracker.yaml).

An example of an API request for inserting metadata is provided below:

Expand Down Expand Up @@ -150,7 +150,7 @@ To partially update existing metadata, an HTTP `PATCH` request to the `/mmds`
resource has to be issued, using as a payload the metadata patch, as
[JSON Merge Patch](https://tools.ietf.org/html/rfc7396) functionality describes.
A complete description of updating metadata Firecracker API can be found in the
[firecracker swagger file](../../src/firecracker/swagger/firecracker.yaml).
[Firecracker OpenAPI specification](../../src/firecracker/openapi/firecracker.yaml).

An example API for how to update existing metadata is offered below:

Expand Down Expand Up @@ -191,7 +191,7 @@ To retrieve existing MMDS metadata from host operating system, an HTTP `GET`
request to the `/mmds` resource must be issued. The HTTP response returns the
existing metadata, as a JSON formatted text. A complete description of
retrieving metadata Firecracker API can be found in the
[firecracker swagger file](../../src/firecracker/swagger/firecracker.yaml).
[Firecracker OpenAPI specification](../../src/firecracker/openapi/firecracker.yaml).

Below you can see how to retrieve metadata from the host:

Expand Down
4 changes: 2 additions & 2 deletions docs/snapshotting/snapshot-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ curl --unix-socket /tmp/firecracker.socket -i \
```

Details about the required and optional fields can be found in the
[swagger definition](../../src/firecracker/swagger/firecracker.yaml).
[OpenAPI specification](../../src/firecracker/openapi/firecracker.yaml).

*Note*: If the files indicated by `snapshot_path` and `mem_file_path` don't
exist at the specified paths, then they will be created right before generating
Expand Down Expand Up @@ -446,7 +446,7 @@ curl --unix-socket /tmp/firecracker.socket -i \
```

Details about the required and optional fields can be found in the
[swagger definition](../../src/firecracker/swagger/firecracker.yaml).
[OpenAPI specification](../../src/firecracker/openapi/firecracker.yaml).

**Prerequisites**: A full memory snapshot and a microVM state file **must** be
provided. The disk backing files, network interfaces backing TAPs and/or vsock
Expand Down
Loading