Skip to content

Default values missing from OpenAPI output #3773

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

Open
lcawl opened this issue Feb 11, 2025 · 0 comments
Open

Default values missing from OpenAPI output #3773

lcawl opened this issue Feb 11, 2025 · 0 comments
Labels

Comments

@lcawl
Copy link
Contributor

lcawl commented Feb 11, 2025

I thought this already existed, but it seems not. For example, looking at https://github.com/elastic/elasticsearch-specification/blob/main/specification/esql/query/QueryRequest.ts, which has @server_default values set like this:

    /**
     * When set to `true` and performing a cross-cluster query, the response will include an extra `_clusters`
     * object with information about the clusters that participated in the search along with info such as shards
     * count.
     * @server_default false
     */
    include_ccs_metadata?: boolean

I can see that same information carried into the specification files, e.g. serverDefault appears for include_ccs_metadata in https://raw.githubusercontent.com/elastic/elasticsearch-specification/refs/heads/main/output/schema/schema-serverless.json

          {
            "description": "When set to `true` and performing a cross-cluster query, the response will include an extra `_clusters`\nobject with information about the clusters that participated in the search along with info such as shards\ncount.",
            "name": "include_ccs_metadata",
            "required": false,
            "serverDefault": false,
            "type": {
              "kind": "instance_of",
              "type": {
                "name": "boolean",
                "namespace": "_builtins"
              }
            }
          }
        ]

However, it's missing from the OpenAPI output. For example:

 "include_ccs_metadata": {
                    "description": "When set to `true` and performing a cross-cluster query, the response will include an extra `_clusters`\nobject with information about the clusters that participated in the search along with info such as shards\ncount.",
                    "type": "boolean"
                  }

It should appear in a default field, as described in https://spec.openapis.org/oas/v3.0.3#properties

In Kibana API documents, those default fields are present in the OpenAPI, for example:

      parameters:
        - description: The number of rules to return per page.
          in: query
          name: per_page
          required: false
          schema:
            default: 10
            minimum: 0
            type: number

... which then is displayed in our docs like this (https://www.elastic.co/docs/api/doc/kibana/operation/operation-get-alerting-rules-find):

Image

@lcawl lcawl added the OpenAPI label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant