-
Notifications
You must be signed in to change notification settings - Fork 30
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
Open
Mohamed-ben-khemis
wants to merge
7
commits into
kubeflow:notebooks-v2
Choose a base branch
from
Mohamed-ben-khemis:feature/swagger
base: notebooks-v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+347
−4
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5f04a46
Add Swagger Config
Mohamed-ben-khemis 5fd2f6f
Removed make watch
Mohamed-ben-khemis f6c56a8
add swag command
Mohamed-ben-khemis 1d4c260
Updated swagger output
Mohamed-ben-khemis 4ae486d
Serve YAML API spec alongside Swagger UI
Mohamed-ben-khemis 191142d
Updated general annotations
Mohamed-ben-khemis 4b188b4
Updated swagger docs version
Mohamed-ben-khemis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
||
|
||
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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/