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

Add support for Elastic-Api-Version header parameter #2747

Open
lcawl opened this issue Jul 29, 2024 · 0 comments
Open

Add support for Elastic-Api-Version header parameter #2747

lcawl opened this issue Jul 29, 2024 · 0 comments

Comments

@lcawl
Copy link
Contributor

lcawl commented Jul 29, 2024

🚀 Feature Proposal

  1. Add Elastic-Api-Version header parameter support within the specification.
  2. Provide a consistent way to qualify behaviour or request/response bodies that differ depending on the header value.

It seems possible this will be easier to implement in future OpenAPI specification versions (e.g. "Support APIs that have different responses based on query parameters, headers and request bodies" mentioned in https://bump.sh/blog/openapi-v4-moonwalk). There doesn't seem to be an official ETA for that release, however, so we need an interim way to move forward.

Motivation

The openAPI documents generated from the specification are currently missing the Elastic-Api-Version header parameter.

Example

In the generated Kibana openAPI documents, this parameter is output as follows:

...
"parameters": [
          {
            "description": "The version of the API to use",
            "in": "header",
            "name": "elastic-api-version",
            "schema": {
              "default": "2023-10-31",
              "enum": [
                "2023-10-31"
              ],
              "type": "string"
            }
          },

To indicate that a request/response body is associated with a specific version, they're qualifying it like this:

"responses": {
          "200": {
            "content": {
              "application/json; Elastic-Api-Version=2023-10-31": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/core_status_response"
                    },
                   ...

Ideally we would want the openAPI document to contain all of the supported Elastic-Api-Version values for a particular branch (and all of the appropriate request and response body variations that match those versions if they differ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant