Skip to content
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
wants to merge 10 commits into
base: notebooks-v2
Choose a base branch
from

Conversation

Mohamed-ben-khemis
Copy link

@Mohamed-ben-khemis Mohamed-ben-khemis commented Feb 12, 2025

Closes #46

Summary

This PR introduces Swagger configuration for the project, enabling API documentation and interactive testing directly from the browser.

Changes Implemented

  • Swagger Setup: Initialized and configured Swagger for the backend.
  • Document Health Check: Added Swagger documentation for the health check endpoint.
  • Ensure Swagger Docs Regeneration: Ensured Swagger documentation is regenerated before each backend build and run.
  • Structured Documentation Output: Configured JSON/YAML documentation output to be stored in api/v1/swagger.
  • Serving API Documentation:
    • Enabled serving the generated YAML documentation in addition to the Swagger UI.

@Mohamed-ben-khemis Mohamed-ben-khemis changed the title feat(ws:) feat(ws): add swagger config Feb 12, 2025
Signed-off-by: mohamed-ben-khemis <[email protected]>
Signed-off-by: mohamed-ben-khemis <[email protected]>
Signed-off-by: mohamed-ben-khemis <[email protected]>
Signed-off-by: mohamed-ben-khemis <[email protected]>
Signed-off-by: mohamed-ben-khemis <[email protected]>
Signed-off-by: mohamed-ben-khemis <[email protected]>
@ederign
Copy link
Member

ederign commented Feb 18, 2025

/ok-to-test

Copy link
Member

@ederign ederign left a comment

Choose a reason for hiding this comment

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

We are on the right path. Just added some comments there:

Also, can we reduce the logs generated?

:no Go files in /Users/ederign/src/kubeflow/notebooks/workspaces/backend
2025/02/18 10:29:57 Generating health_check.HealthCheck
2025/02/18 10:29:57 Generating health_check.ServiceStatus
2025/02/18 10:29:57 Generating health_check.SystemInfo
2025/02/18 10:29:57 Generating api.ErrorResponse
2025/02/18 10:29:57 create docs.go at api/v1/swagger/docs.go
2025/02/18 10:29:57 create swagger.json at api/v1/swagger/swagger.json
2025/02/18 10:29:57 create swagger.yaml at api/v1/swagger/swagger.yaml

##@ Swagger

.PHONY: swag
swag:
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

@@ -0,0 +1,110 @@
// Package swagger Code generated by swaggo/swag. DO NOT EDIT
package swagger
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Author

@Mohamed-ben-khemis Mohamed-ben-khemis Feb 19, 2025

Choose a reason for hiding this comment

The 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).

@ederign
Copy link
Member

ederign commented Feb 18, 2025

Great progress @Mohamed-ben-khemis take a look on our tests that are failing due to lack of binary.

Also, 7 warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /Users/ederign/src/kubeflow/notebooks/workspaces/backend

@google-oss-prow google-oss-prow bot added size/XL and removed size/L labels Feb 19, 2025
@Mohamed-ben-khemis
Copy link
Author

We are on the right path. Just added some comments there:

Also, can we reduce the logs generated?

:no Go files in /Users/ederign/src/kubeflow/notebooks/workspaces/backend
2025/02/18 10:29:57 Generating health_check.HealthCheck
2025/02/18 10:29:57 Generating health_check.ServiceStatus
2025/02/18 10:29:57 Generating health_check.SystemInfo
2025/02/18 10:29:57 Generating api.ErrorResponse
2025/02/18 10:29:57 create docs.go at api/v1/swagger/docs.go
2025/02/18 10:29:57 create swagger.json at api/v1/swagger/swagger.json
2025/02/18 10:29:57 create swagger.yaml at api/v1/swagger/swagger.yaml

Done! I've added quiet mode to swag init
swag init
Screenshot at Feb 19 14-28-27

@Mohamed-ben-khemis
Copy link
Author

Great progress @Mohamed-ben-khemis take a look on our tests that are failing due to lack of binary.

Also, 7 warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /Users/ederign/src/kubeflow/notebooks/workspaces/backend
Fixed swag init by adjusting directory selection. Now it properly processes Go files, excluding cmd/, and runs without warning.

image

@ederign
Copy link
Member

ederign commented Feb 27, 2025

/assign @ederign

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ederign
Once this PR has been reviewed and has the lgtm label, please assign kimwnasptd for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ederign
Copy link
Member

ederign commented Feb 27, 2025

Nice work @Mohamed-ben-khemis! This is a good starting point for our swagger generation. Let's review it on the call today with @thesuperzapper, and my suggestion would be for you to start the other endpoints!

@ederign
Copy link
Member

ederign commented Feb 27, 2025

/lgtm

@google-oss-prow google-oss-prow bot added the lgtm label Feb 27, 2025
@ederign
Copy link
Member

ederign commented Feb 27, 2025

Screenshot of this running:

Screenshot 2025-02-27 at 11 10 01 AM

@Mohamed-ben-khemis
Copy link
Author

Nice work @Mohamed-ben-khemis! This is a good starting point for our swagger generation. Let's review it on the call today with @thesuperzapper, and my suggestion would be for you to start the other endpoints!

Great! Thanks for the review @ederign. Now that this is merged, I'll begin working on the other endpoints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

2 participants