Today, Fleet's OpenAPI spec file is generated and maintained through a manual process documented in the README file in x-pack/fleet/plugins/fleet/common/openapi/.
Kibana as a whole is moving towards support for fully-automated OpenAPI specs for plugin APIs, as tracked here: https://github.com/elastic/kibana/issues/180056. Fleet's manual process should be replaced by a fully automated one in which the OAS spec is inferred from metadata on our server-side routes and request/response contracts defined via @kbn/config-schema.
We had previously done some investigation into whether @kbn/openapi-generator was ready to meet Fleet's needs and the answer at the time was "no". However, with a few months of progress since then, we should start the process of moving towards automating our schema generation. Manually generating and maintaining our OpenAPI spec is labor intensive and error prone, so shedding this friction will speed up our development process on the team.
Here is an example of the /api/status Kibana API's schema written with @kbn/config-schema that results in an OpenAPI spec here:
What we'll actually need to do to accomplish this is to replace each entry we have today in Fleet's OpenAPI spec files with a more advanced set of types created with @kbn/config-schema alongside each route we register.
An example of this for the /api/fleet/setup API might look like this:
Each documented status code, response body, query parameter, etc can be documented directly alongside the route definition. We'd need to take what we have today in the various OpenAPI spec files and translate them to this approach for every Fleet API endpoint. This will be no small undertaking, but it will greatly improve our ability to create or iterate on API endpoints It will also greatly empower our docs team to generate better API documentation.
Today, Fleet's OpenAPI spec file is generated and maintained through a manual process documented in the README file in
x-pack/fleet/plugins/fleet/common/openapi/
.Kibana as a whole is moving towards support for fully-automated OpenAPI specs for plugin APIs, as tracked here: https://github.com/elastic/kibana/issues/180056. Fleet's manual process should be replaced by a fully automated one in which the OAS spec is inferred from metadata on our server-side routes and request/response contracts defined via
@kbn/config-schema
.We had previously done some investigation into whether
@kbn/openapi-generator
was ready to meet Fleet's needs and the answer at the time was "no". However, with a few months of progress since then, we should start the process of moving towards automating our schema generation. Manually generating and maintaining our OpenAPI spec is labor intensive and error prone, so shedding this friction will speed up our development process on the team.Here is an example of the
/api/status
Kibana API's schema written with@kbn/config-schema
that results in an OpenAPI spec here:https://github.com/elastic/kibana/blob/3efa595a9ad52e63324fc3009ab7c9fb52174eed/oas_docs/bundle.json#L451-L525
What we'll actually need to do to accomplish this is to replace each entry we have today in Fleet's OpenAPI spec files with a more advanced set of types created with
@kbn/config-schema
alongside each route we register.An example of this for the
/api/fleet/setup
API might look like this:Each documented status code, response body, query parameter, etc can be documented directly alongside the route definition. We'd need to take what we have today in the various OpenAPI spec files and translate them to this approach for every Fleet API endpoint. This will be no small undertaking, but it will greatly improve our ability to create or iterate on API endpoints It will also greatly empower our docs team to generate better API documentation.