-
Notifications
You must be signed in to change notification settings - Fork 33
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
feat(ws): add swagger config #206
base: notebooks-v2
Are you sure you want to change the base?
Changes from 7 commits
5f04a46
5fd2f6f
f6c56a8
1d4c260
4ae486d
191142d
4b188b4
90ad053
b76c9fd
d4b3e0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Package swagger Code generated by swaggo/swag. DO NOT EDIT | ||
package swagger | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I mention on other, my suggestion is to serialize into another folder (i.e. openapi) on root of backend There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! It's now generating into the openapi folder at the root of the backend(backend/openapi). |
||
|
||
import "github.com/swaggo/swag" | ||
|
||
const docTemplate = `{ | ||
"schemes": {{ marshal .Schemes }}, | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "{{escape .Description}}", | ||
"title": "{{.Title}}", | ||
"contact": {}, | ||
"license": { | ||
"name": "License: Apache 2.0", | ||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" | ||
}, | ||
"version": "{{.Version}}" | ||
}, | ||
"host": "{{.Host}}", | ||
"basePath": "{{.BasePath}}", | ||
"paths": { | ||
"/healthcheck": { | ||
"get": { | ||
"description": "Provides a healthcheck response indicating the status of key services.", | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"healthcheck" | ||
], | ||
"summary": "Returns the health status of the application", | ||
"responses": { | ||
"200": { | ||
"description": "Successful healthcheck response", | ||
"schema": { | ||
"$ref": "#/definitions/health_check.HealthCheck" | ||
} | ||
}, | ||
"500": { | ||
"description": "Internal server error", | ||
"schema": { | ||
"$ref": "#/definitions/api.ErrorResponse" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"api.ErrorResponse": { | ||
"type": "object", | ||
"properties": { | ||
"code": { | ||
"type": "string" | ||
}, | ||
"message": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"health_check.HealthCheck": { | ||
"type": "object", | ||
"properties": { | ||
"status": { | ||
"$ref": "#/definitions/health_check.ServiceStatus" | ||
}, | ||
"system_info": { | ||
"$ref": "#/definitions/health_check.SystemInfo" | ||
} | ||
} | ||
}, | ||
"health_check.ServiceStatus": { | ||
"type": "string", | ||
"enum": [ | ||
"Healthy", | ||
"Unhealthy" | ||
], | ||
"x-enum-varnames": [ | ||
"ServiceStatusHealthy", | ||
"ServiceStatusUnhealthy" | ||
] | ||
}, | ||
"health_check.SystemInfo": { | ||
"type": "object", | ||
"properties": { | ||
"version": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
}` | ||
|
||
// SwaggerInfo holds exported Swagger Info so clients can modify it | ||
var SwaggerInfo = &swag.Spec{ | ||
Version: "1.0.0", | ||
Host: "localhost:4000", | ||
BasePath: "/api/v1", | ||
Schemes: []string{"http", "https"}, | ||
Title: "Kubeflow Notebooks API", | ||
Description: "This API provides endpoints to manage notebooks in a Kubernetes cluster.\nFor more information, visit https://www.kubeflow.org/docs/components/notebooks/", | ||
InfoInstanceName: "swagger", | ||
SwaggerTemplate: docTemplate, | ||
LeftDelim: "{{", | ||
RightDelim: "}}", | ||
} | ||
|
||
func init() { | ||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"schemes": [ | ||
"http", | ||
"https" | ||
], | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "This API provides endpoints to manage notebooks in a Kubernetes cluster.\nFor more information, visit https://www.kubeflow.org/docs/components/notebooks/", | ||
"title": "Kubeflow Notebooks API", | ||
"contact": {}, | ||
"license": { | ||
"name": "License: Apache 2.0", | ||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" | ||
}, | ||
"version": "1.0.0" | ||
}, | ||
"host": "localhost:4000", | ||
"basePath": "/api/v1", | ||
"paths": { | ||
"/healthcheck": { | ||
"get": { | ||
"description": "Provides a healthcheck response indicating the status of key services.", | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"healthcheck" | ||
], | ||
"summary": "Returns the health status of the application", | ||
"responses": { | ||
"200": { | ||
"description": "Successful healthcheck response", | ||
"schema": { | ||
"$ref": "#/definitions/health_check.HealthCheck" | ||
} | ||
}, | ||
"500": { | ||
"description": "Internal server error", | ||
"schema": { | ||
"$ref": "#/definitions/api.ErrorResponse" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"api.ErrorResponse": { | ||
"type": "object", | ||
"properties": { | ||
"code": { | ||
"type": "string" | ||
}, | ||
"message": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"health_check.HealthCheck": { | ||
"type": "object", | ||
"properties": { | ||
"status": { | ||
"$ref": "#/definitions/health_check.ServiceStatus" | ||
}, | ||
"system_info": { | ||
"$ref": "#/definitions/health_check.SystemInfo" | ||
} | ||
} | ||
}, | ||
"health_check.ServiceStatus": { | ||
"type": "string", | ||
"enum": [ | ||
"Healthy", | ||
"Unhealthy" | ||
], | ||
"x-enum-varnames": [ | ||
"ServiceStatusHealthy", | ||
"ServiceStatusUnhealthy" | ||
] | ||
}, | ||
"health_check.SystemInfo": { | ||
"type": "object", | ||
"properties": { | ||
"version": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
basePath: /api/v1 | ||
definitions: | ||
api.ErrorResponse: | ||
properties: | ||
code: | ||
type: string | ||
message: | ||
type: string | ||
type: object | ||
health_check.HealthCheck: | ||
properties: | ||
status: | ||
$ref: '#/definitions/health_check.ServiceStatus' | ||
system_info: | ||
$ref: '#/definitions/health_check.SystemInfo' | ||
type: object | ||
health_check.ServiceStatus: | ||
enum: | ||
- Healthy | ||
- Unhealthy | ||
type: string | ||
x-enum-varnames: | ||
- ServiceStatusHealthy | ||
- ServiceStatusUnhealthy | ||
health_check.SystemInfo: | ||
properties: | ||
version: | ||
type: string | ||
type: object | ||
host: localhost:4000 | ||
info: | ||
contact: {} | ||
description: |- | ||
This API provides endpoints to manage notebooks in a Kubernetes cluster. | ||
For more information, visit https://www.kubeflow.org/docs/components/notebooks/ | ||
license: | ||
name: 'License: Apache 2.0' | ||
url: http://www.apache.org/licenses/LICENSE-2.0.html | ||
title: Kubeflow Notebooks API | ||
version: 1.0.0 | ||
paths: | ||
/healthcheck: | ||
get: | ||
description: Provides a healthcheck response indicating the status of key services. | ||
produces: | ||
- application/json | ||
responses: | ||
"200": | ||
description: Successful healthcheck response | ||
schema: | ||
$ref: '#/definitions/health_check.HealthCheck' | ||
"500": | ||
description: Internal server error | ||
schema: | ||
$ref: '#/definitions/api.ErrorResponse' | ||
summary: Returns the health status of the application | ||
tags: | ||
- healthcheck | ||
schemes: | ||
- http | ||
- https | ||
swagger: "2.0" |
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.
We will have to add instructions to either user install it or make sure that we install as binary. Do you think we can do similar to what we do on bin? with env test?
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.
Also, other kubeflow projects "version" the file under api folder:
https://github.com/kubeflow/model-registry/tree/main/api/
https://github.com/kubeflow/pipelines/tree/master/api
Can we do the same? If we have the generated file inside our codebase we add easily to kubeflow docs.
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.
Similar to https://www.kubeflow.org/docs/components/model-registry/reference/rest-api/