Skip to content

[Doc] OpenAPI spec #17292

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

Merged
merged 46 commits into from
Mar 14, 2025
Merged

[Doc] OpenAPI spec #17292

merged 46 commits into from
Mar 14, 2025

Conversation

kaisecheng
Copy link
Contributor

@kaisecheng kaisecheng commented Mar 8, 2025

Release notes

Migrate API doc to OpenAPI spec

What does this PR do?

  • break down the share part to components
  • add the missing fields for Plugins info, Node stats, Node Info, Hot threads and Health report
  • expand Node Info /_node/<types> to /_node/jvm, /_node/pipelines and /_node/os
  • expand Node Stats to /_node/stats, /_node/stats/pipelines, /_node/stats/pipelines/{pipeline_name}, /_node/stats/jvm, /_node/stats/flow, /_node/stats/events, /_node/stats/process, /_node/stats/reloads

Why is it important/What is the impact to the user?

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works

Author's Checklist

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

Copy link
Contributor

mergify bot commented Mar 8, 2025

This pull request does not have a backport label. Could you fix it @kaisecheng? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • backport-8.x is the label to automatically backport to the 8.x branch.
  • If no backport is necessary, please add the backport-skip label

Copy link
Contributor

github-actions bot commented Mar 8, 2025

Copy link
Contributor

@karenzone
Copy link
Contributor

karenzone commented Mar 10, 2025

Related: #16594
@kaisecheng, we're working on getting the validation PR working for Logstash, too. 🤞
Thanks for your work on this.

Also tagging @lcawl as our resident API guru.

@karenzone karenzone assigned karenzone and kaisecheng and unassigned karenzone Mar 10, 2025
@karenzone karenzone requested review from lcawl and karenzone March 10, 2025 20:51
@karenzone karenzone added the docs label Mar 10, 2025
Copy link
Contributor

Copy link
Contributor

@karenzone karenzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaisecheng, I generated a BUMP.SH preview, and this is looking good! Thanks for fleshing out so much of the content. Please keep it going!
Bump links expire after a short time, but I'm happy to pull down new content and generate a new link
anytime you'd like for me to.

type: object
additionalProperties:
description: "pipeline name"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that description makes sense in this context, so IMO it either needs to be improved or removed.

Suggested change
description: "pipeline name"

Copy link
Contributor Author

@kaisecheng kaisecheng Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In OpenAPI, additionalProperties means a map structure where the key / field name is dynamic generated

{ 
  additionalProperty1: { ... }
  additionalProperty2: { ... }
}

Description is to tell user the dynamic part additionalProperty1 is a pipeline name, where the pipeline name is a user defined value.

Take a static field example from _node/os

{
  "os": {
    "name": "Mac OS X",
    "arch": "x86_64",
    "version": "10.12.4",
    "available_processors": 8
  }
}

os, name, arch, version, available_processors never change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the description to explain the key and value

@lcawl
Copy link
Contributor

lcawl commented Mar 12, 2025

Hi! When I run npx @redocly/cli lint logstash-api.yaml --config redocly.yaml there are a few messages that I think are worth fixing. For example:

[1] logstash-api.yaml:343:5 at #/paths/1_node1stats~1events/get/operationId
Operation object should contain operationId field.

The operationId uniquely identifies the operation. It is case sensitive and must be unique in the OpenAPI document. It is recommended to use camel case (for example, createConnector).
Our docs use this value when generating the URL, therefore it's better to explicitly define it than rely on something automated.

The rest of my suggestions are just style-related and shouldn't be considered blockers. Thanks for creating this content!

- add links and description
- add infinity to flow window
- fix flow stats component
@kaisecheng kaisecheng changed the title [WIP] [Doc] OpenAPI spec [Doc] OpenAPI spec Mar 13, 2025
@kaisecheng kaisecheng marked this pull request as ready for review March 13, 2025 23:16
@kaisecheng
Copy link
Contributor Author

kaisecheng commented Mar 13, 2025

@karenzone @lcawl Many thanks for helping to build the doc. I think this is ready for another review.

  • copy the description and links from the current doc to markdown
  • comment out the repeated common response for a cleaner presentation
#                  - $ref: '#/components/schemas/Common'
#                  - $ref: '#/components/schemas/PipelineSettings'
  • add examples for all APIs
  • some fixes of components
  • update authentication to basic

Copy link
Contributor

example: ["pipeline_execution"]
items:
type: string
diagnosis:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

                               diagnosis:

There's a linting error related to this definition:

[9] logstash-api.yaml:1455:33 at #/paths/~1_health_report/get/responses/200/content/application~1json/examples/backpressureCase/value/indicators/pipelines/indicators/blocked-pipeline/diagnosis/0/id

Example value must conform to the schema: `0` property must NOT have unevaluated properties `id`.

1453 | symptom: "The pipeline is unhealthy; 1 area is impacted and 1 diagnosis is available"
1454 | diagnosis:
1455 |   - id: "logstash:health:pipeline:flow:worker_utilization:diagnosis:5m-blocked"
1456 |     cause: "pipeline workers have been completely blocked for at least five minutes"
1457 |     action: "address bottleneck or add resources"

referenced from logstash-api.yaml:1313:15 at #/paths/~1_health_report/get/responses/200/content/application~1json 

Warning was generated by the no-invalid-media-type-examples rule.

I think this means the id value that appears in the example is missing from this schema definition.

Copy link
Contributor

@andsel andsel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking with https://editor-next.swagger.io/ I got this warnings:

severity line code Message
Warning 1319 10069 property "example" is deprecated, use "examples" instead
Warning 1342 10069 property "example" is deprecated, use "examples" instead
Warning 1379 10069 property "example" is deprecated, use "examples" instead
Hint 1506 10071 nullable has no special meaning, if not set on purpose use type="null" instead
Hint 2010 10071 nullable has no special meaning, if not set on purpose use type="null" instead
Hint 2017 10071 nullable has no special meaning, if not set on purpose use type="null" instead
Hint 2021 10071 nullable has no special meaning, if not set on purpose use type="null" instead

- add id to health report
- fix typo
- add comment for the usage of allOf
Copy link
Contributor

@kaisecheng
Copy link
Contributor Author

@andsel example and examples are both valid in openAPI 3.1
I saw the same warning but found examples structure is overkilled. examples requires a single example to be in array form, so I choose to ignore the warning.

@robbavey
Copy link
Member

@andsel - If @kaisecheng has addressed your concerns, can you please remove the requests changes status from your PR

Copy link
Contributor

@karenzone karenzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaisecheng, thank you for all of the thought and effort you put into this project. LGTM!

@andsel andsel self-requested a review March 14, 2025 14:30
Copy link
Contributor

@andsel andsel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

Copy link
Contributor

@lcawl lcawl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM2, thanks for addressing all my suggestions!

@kaisecheng
Copy link
Contributor Author

Thank you all for your suggestions! It looks good

@kaisecheng kaisecheng merged commit 4779d5e into elastic:main Mar 14, 2025
7 of 8 checks passed
Copy link
Contributor

@karenzone
Copy link
Contributor

PUBLISHED: https://www.elastic.co/docs/api/doc/logstash/
Thanks for publishing, @lcawl

@yaauie yaauie mentioned this pull request Mar 17, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Logstash API] Complete API doc migration to OpenAPI spec
5 participants