-
Notifications
You must be signed in to change notification settings - Fork 713
fix: OpenAPI descriptions for endpoints #8231
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR significantly improves OpenAPI documentation quality by upgrading utoipa from v4.0.0 to v5.0.0 and utoipa-swagger-ui from v4.0.0 to v9.0.0, while systematically adding explicit summary and description fields to all HTTP endpoint handlers. The changes address a fundamental issue where OpenAPI descriptions were previously auto-generated from Rust doc comments, which could leak development-specific information into the public API specification and provided limited control over documentation quality.
The PR touches over 60 files across the entire HTTP API surface, adding comprehensive endpoint descriptions that explain functionality, use cases, parameters, and business logic in user-friendly terms. Response body annotations have been standardized, replacing specific types like HttpResponse with more appropriate generic types (Object for JSON responses, () for empty responses) to improve OpenAPI schema accuracy.
Additionally, the PR adds ToSchema derive macros and schema annotations (#[schema(value_type = ...)]) to numerous data structures throughout the codebase. These annotations ensure that complex internal types like Ksuid, OrdF64, and DateTime are properly represented as simple strings and numbers in the generated API specification, rather than exposing internal Rust type complexity to API consumers.
The changes maintain complete backward compatibility in terms of actual API behavior while dramatically improving the quality and professionalism of the generated OpenAPI documentation. This represents a comprehensive effort to create clean, controlled API documentation that's suitable for external consumption and tooling integration.
Confidence score: 3/5
- This PR requires careful review due to potential runtime issues and logical errors in several files
- Score reflects concerns about duplicate code, type mismatches, and unsafe operations that could cause production problems
- Pay close attention to organization/settings.rs, clusters/mod.rs, metrics/ingest.rs, actions/action.rs, and folders.rs for critical issues
61 files reviewed, 14 comments
| ("name" = String, Path, description = "Function name"), | ||
| ), | ||
| responses( | ||
| (status = 200, description = "Success", content_type = "application/json", body = FunctionList), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Response body type mismatch: the endpoint returns pipeline dependencies but body type is FunctionList, which contains Transform objects rather than pipeline dependency information
| #[utoipa::path( | ||
| context_path = "/api", | ||
| tag = "Roles", | ||
| operation_id = "GetRoLesUsers", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Typo in operation_id: "GetRoLesUsers" should be "GetRoleUsers"
| operation_id = "GetRoLesUsers", | |
| operation_id = "GetRoleUsers", |
| ("org_id" = String, Path, description = "Organization name") | ||
| ), | ||
| responses( | ||
| (status = StatusCode::OK, description = "Prompt rolled back to default", body = PromptResponse), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Response body type inconsistent: returns PromptResponse but endpoint returns NoContent on success (line 206)
| (status = StatusCode::OK, description = "Prompt rolled back to default", body = PromptResponse), | |
| (status = StatusCode::NO_CONTENT, description = "Prompt rolled back to default"), |
| (status = 200, description = "Success", content_type = "application/json", body = | ||
| HttpResponse), (status = 400, description = "Error", content_type = "application/json", | ||
| body = HttpResponse), ) | ||
| request_body(content = Template, description = "Template data", content_type = "application/json"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: GET endpoints should not specify request_body. Remove this line.
| request_body(content = Template, description = "Template data", content_type = "application/json"), | |
| responses( |
| ("org_id" = String, Path, description = "Organization name (must be meta org)"), | ||
| ), | ||
| responses( | ||
| (status = 200, description = "Success", content_type = "application/json", body = DomainManagementResponse), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Response body type references 'DomainManagementResponse' but this type isn't imported or visible in this file
| ), | ||
| request_body(content = DomainManagementRequest, description = "Domain management configuration", content_type = "application/json"), | ||
| responses( | ||
| (status = 200, description = "Success", content_type = "application/json", body = DomainOperationResponse), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Response body type references 'DomainOperationResponse' but this type isn't imported or visible in this file
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
3fedb10 to
4b67762
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR comprehensively overhauls the OpenAPI documentation generation across the entire OpenObserve codebase. The changes upgrade utoipa from 4.0.0 to 5.0.0 and utoipa-swagger-ui from 4.0.0 to 9.0.0, enabling better control over API documentation. The core improvement detaches OpenAPI endpoint descriptions from Rust doc comments by adding explicit summary and description fields to all endpoint annotations. This prevents development-specific information from leaking into the public API specification.
The PR systematically updates response body schemas across hundreds of endpoints, replacing specific internal types (like HttpResponse, SearchResponse, Pipeline) with generic OpenAPI-friendly types (Object for successful JSON responses and () for empty responses). Schema annotations are added to custom types like Ksuid, OrdF64, and DateTime<Utc> fields to ensure proper OpenAPI type representation. Complex internal structures are simplified to generic Object types in the documentation while maintaining type safety in the actual implementation.
The changes span all major functional areas including alerts, dashboards, search APIs, user management, organization settings, metrics ingestion, PromQL endpoints, streaming APIs, and enterprise features like RBAC. Each endpoint now has professional, user-facing documentation with clear explanations of functionality, use cases, and expected behavior. The upgrade also required updating HTTP method enumeration logic in the OpenAPI info function to work with the new utoipa 5.0.0 API structure.
Confidence score: 4/5
- This PR requires careful review due to extensive OpenAPI documentation changes across the entire codebase and potential breaking changes from major version upgrades
- Score reflects the comprehensive nature of changes affecting API documentation generation and the need to verify that all endpoints maintain correct schema representations
- Pay close attention to response body schema changes and endpoint parameter annotations, particularly in critical endpoints like authentication, billing, and data ingestion
69 files reviewed, 4 comments
| description = "Ingests metrics data using OpenTelemetry Protocol (OTLP) format. Supports both Protocol Buffers and JSON \ | ||
| content types for OTLP metrics ingestion. This is the standard endpoint for OpenTelemetry SDK and \ | ||
| collector integrations to send metrics data.", | ||
| request_body(content = String, description = "ExportMetricsServiceRequest", content_type = "application/x-protobuf"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Missing params section for org_id parameter - all other similar endpoints in the PR include this parameter documentation
| request_body(content = String, description = "ExportMetricsServiceRequest", content_type = "application/x-protobuf"), | |
| params( | |
| ("org_id" = String, Path, description = "Organization name"), | |
| ), | |
| request_body(content = String, description = "ExportMetricsServiceRequest", content_type = "application/x-protobuf"), |
| (status = 200, description = "Success", content_type = "application/json", body = | ||
| HttpResponse), (status = 400, description = "Error", content_type = "application/json", | ||
| body = HttpResponse), ) | ||
| Object), (status = 400, description = "Error", content_type = "application/json", | ||
| body = ()), ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Formatting issue: response body definition is split across multiple lines inconsistently
| (status = 200, description = "Success", content_type = "application/json", body = | |
| HttpResponse), (status = 400, description = "Error", content_type = "application/json", | |
| body = HttpResponse), ) | |
| Object), (status = 400, description = "Error", content_type = "application/json", | |
| body = ()), ) | |
| (status = 200, description = "Success", content_type = "application/json", body = Object), | |
| (status = 400, description = "Error", content_type = "application/json", body = ()), |
| /// #{"ratelimit_module":"Reports", "ratelimit_module_operation":"update"}# | ||
| #[utoipa::path( | ||
| context_path = "/api", | ||
| tag = "Report", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Tag inconsistency: should be 'Reports' to match other endpoints in this file
| tag = "Report", | |
| tag = "Reports", |
| (status = 200, description = "Success", content_type = "application/json", body = | ||
| HttpResponse), (status = 400, description = "Error", content_type = "application/json", | ||
| body = HttpResponse), ) | ||
| Object), (status = 400, description = "Error", content_type = "application/json", | ||
| body = ()), ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Formatting issue: response body definition is split across multiple lines inconsistently
| (status = 200, description = "Success", content_type = "application/json", body = | |
| HttpResponse), (status = 400, description = "Error", content_type = "application/json", | |
| body = HttpResponse), ) | |
| Object), (status = 400, description = "Error", content_type = "application/json", | |
| body = ()), ) | |
| (status = 200, description = "Success", content_type = "application/json", body = Object), | |
| (status = 400, description = "Error", content_type = "application/json", body = ()), |
4b67762 to
4803d49
Compare
4803d49 to
1f8bd2f
Compare
9a557a5 to
d9624b0
Compare
So far the OpenAPI descriptions for endpoint handlers was directly derived from the doc comments, leaving little control. This also leaked any dev-specific information into API spec. Now the summary and description are explicitly populated for all the endpoints, detaching them from doc comments. Also update response body annotations wherever necessary Also bump - utoipa: 4.0.0 -> 5.0.0 - utoipa-swagger-ui: 4.0.0 -> 9.0.0
d9624b0 to
c081351
Compare
User description
So far the OpenAPI descriptions for endpoint handlers was directly derived from the doc comments, leaving little control. This also leaked any dev-specific information into API spec.
Now the summary and description are explicitly populated for all the endpoints, detaching them from doc comments.
Also update response body annotations wherever necessary
Also bump
PR Type
Documentation, Enhancement
Description
Add explicit OpenAPI summaries/descriptions
Correct response body schemas to Object/()
Update params/types for accuracy
Improve endpoint examples and metadata
Diagram Walkthrough
File Walkthrough
12 files
Add summaries and fix response schemas for RBAC endpointsDocument Prometheus APIs and correct response bodiesEnhance organization endpoints docs and schemasAdd alert API summaries; fix IDs and bodiesMark deprecated alert APIs with summaries and schema fixesAdd folder API docs; adjust response body typesImprove search API docs; use Object and () schemasAdd ingestion endpoint summaries; fix response schemasDocument reports APIs; switch responses to ()/ObjectAdd dashboard API summaries and correct responsesUse Object for error responses; import ObjectAdd clusters listing endpoint description51 files