From 6a9df0b75b5179abb3f25dd2fa0356ad104bfae1 Mon Sep 17 00:00:00 2001 From: jinjia Date: Sun, 2 Feb 2025 16:53:10 +0200 Subject: [PATCH] docs: add /server-configs (#769) ## What type of PR is this? /kind documentation ## What this PR does / why we need it: Include /server-configs endpoint details in Swagger documentation. Missing line breaks in the description field of docs/api.md. ## Which issue(s) this PR fixes: Fixes # --- api/openapispec/docs.go | 21 +++++++++++++++++ api/openapispec/swagger.json | 21 +++++++++++++++++ api/openapispec/swagger.yaml | 14 +++++++++++ docs/api.md | 45 ++++++++++++++++++++++++++---------- pkg/core/route/route.go | 6 +++++ 5 files changed, 95 insertions(+), 12 deletions(-) diff --git a/api/openapispec/docs.go b/api/openapispec/docs.go index edb71689..436503b4 100644 --- a/api/openapispec/docs.go +++ b/api/openapispec/docs.go @@ -2103,6 +2103,27 @@ var doc = `{ } } } + }, + "/server-configs": { + "get": { + "description": "Returns server configuration", + "produces": [ + "application/json" + ], + "tags": [ + "debug" + ], + "summary": "Get server configurations", + "responses": { + "200": { + "description": "Server configurations", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } } }, "definitions": { diff --git a/api/openapispec/swagger.json b/api/openapispec/swagger.json index 5262536c..aa91bddc 100644 --- a/api/openapispec/swagger.json +++ b/api/openapispec/swagger.json @@ -2087,6 +2087,27 @@ } } } + }, + "/server-configs": { + "get": { + "description": "Returns server configuration", + "produces": [ + "application/json" + ], + "tags": [ + "debug" + ], + "summary": "Get server configurations", + "responses": { + "200": { + "description": "Server configurations", + "schema": { + "type": "object", + "additionalProperties": true + } + } + } + } } }, "definitions": { diff --git a/api/openapispec/swagger.yaml b/api/openapispec/swagger.yaml index 41e2c8d1..c78247dd 100644 --- a/api/openapispec/swagger.yaml +++ b/api/openapispec/swagger.yaml @@ -1658,4 +1658,18 @@ paths: using the query from context. tags: - search + /server-configs: + get: + description: Returns server configuration + produces: + - application/json + responses: + "200": + description: Server configurations + schema: + additionalProperties: true + type: object + summary: Get server configurations + tags: + - debug swagger: "2.0" diff --git a/docs/api.md b/docs/api.md index b38389af..5826151d 100644 --- a/docs/api.md +++ b/docs/api.md @@ -59,6 +59,7 @@ Karpor is a brand new Kubernetes visualization tool that focuses on search, insi | Method | URI | Name | Summary | |---------|---------|--------|---------| | GET | /endpoints | [get endpoints](#get-endpoints) | List all available endpoints | +| GET | /server-configs | [get server configs](#get-server-configs) | Get server configurations | @@ -1793,6 +1794,34 @@ Status: Internal Server Error +### Get server configurations (*GetServerConfigs*) + +``` +GET /server-configs +``` + +Returns server configuration + +#### Produces + * application/json + +#### All responses +| Code | Status | Description | Has headers | Schema | +|------|--------|-------------|:-----------:|--------| +| [200](#get-server-configs-200) | OK | Server configurations | | [schema](#get-server-configs-200-schema) | + +#### Responses + + +##### 200 - Server configurations +Status: OK + +###### Schema + + + +any + ### Diagnose events using AI (*PostInsightAggregatorEventDiagnosisStream*) ``` @@ -2894,16 +2923,10 @@ Status: Internal Server Error | Name | Type | Go type | Required | Default | Description | Example | |------|------|---------|:--------:| ------- |-------------|---------| -| issuesTotal | integer| `int64` | | | IssuesTotal is the total count of all issues found during the audit. -This count can be used to understand the overall number of problems -that need to be addressed. | | +| issuesTotal | integer| `int64` | | | IssuesTotal is the total count of all issues found during the audit.
This count can be used to understand the overall number of problems
that need to be addressed. | | | resourceTotal | integer| `int64` | | | ResourceTotal is the count of unique resources audited during the scan. | | -| score | number| `float64` | | | Score represents the calculated score of the audited manifest based on -the number and severity of issues. It provides a quantitative measure -of the security posture of the resources in the manifest. | | -| severityStatistic | map of integer| `map[string]int64` | | | SeverityStatistic is a mapping of severity levels to their respective -number of occurrences. It allows for a quick overview of the distribution -of issues across different severity categories. | | +| score | number| `float64` | | | Score represents the calculated score of the audited manifest based on
the number and severity of issues. It provides a quantitative measure
of the security posture of the resources in the manifest. | | +| severityStatistic | map of integer| `map[string]int64` | | | SeverityStatistic is a mapping of severity levels to their respective
number of occurrences. It allows for a quick overview of the distribution
of issues across different severity categories. | | @@ -2986,8 +3009,6 @@ of issues across different severity categories. | | | Name | Type | Go type | Required | Default | Description | Example | |------|------|---------|:--------:| ------- |-------------|---------| -| object | [interface{}](#interface)| `interface{}` | | | Object is a JSON compatible map with string, float, int, bool, []interface{}, or -map[string]interface{} -children. | | +| object | [interface{}](#interface)| `interface{}` | | | Object is a JSON compatible map with string, float, int, bool, []interface{}, or
map[string]interface{}
children. | | diff --git a/pkg/core/route/route.go b/pkg/core/route/route.go index 3c336712..c3cded43 100644 --- a/pkg/core/route/route.go +++ b/pkg/core/route/route.go @@ -192,6 +192,12 @@ func setupRestAPIV1( r.Get("/authn", authnhandler.Get()) } +// @Summary Get server configurations +// @Description Returns server configuration +// @Tags debug +// @Produce json +// @Success 200 {object} map[string]interface{} "Server configurations" +// @Router /server-configs [get] func customVarHandler() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json")