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: Add swagger UI #193

Merged
merged 15 commits into from
Aug 12, 2024
Merged

Conversation

patriciareinoso
Copy link
Contributor

@patriciareinoso patriciareinoso commented Jun 28, 2024

Description

This PR adds a service for swagger UI docs.
This is an optional functionality, default behavior is not changed.

image

The swagger UI for the API documentation is automatically generated from annotations.

How to use it:

To generate the swagger UI files run:

swag init -g backend/webui_service/swagger_ui_service.go --outputTypes go

The docs.go file will automatically be created in webconsole/docs

The swagger UI runs by default on localhost. If the webconsole server runs remotely, set the following environment variable.

export WEBUI_ENDPOINT=<webconsole-ip>:5000

Build the webconsole including the UI option:

make webconsole-ui

Access the swagger UI at:

http://<webconsole-ip>:5000/swagger/index.html

The doc.json file, which can be integrated in a frontend implementation, is available at:

http://<webconsole-ip>:5000/swagger/doc.json

Documentation for code annotations

https://github.com/swaggo/swag

Rationale

Swagger UI provides interactive API documentation where developers can see available endpoints, their parameters, and expected responses. They can also test endpoints directly from the documentation interface, making it easier to understand and use the API.

Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
docs/docs.go Outdated Show resolved Hide resolved
@thakurajayL
Copy link
Contributor

Do you welcome comments in draft status?

…nto add-swagger-ui

Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
@patriciareinoso patriciareinoso marked this pull request as ready for review July 17, 2024 10:27
Copy link
Contributor

@gatici gatici left a comment

Choose a reason for hiding this comment

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

Looks Good.

configapi/api_default.go Outdated Show resolved Hide resolved
configapi/api_sub_config.go Outdated Show resolved Hide resolved
configapi/api_sub_config.go Outdated Show resolved Hide resolved
configapi/api_sub_config.go Outdated Show resolved Hide resolved
@gab-arrobo
Copy link
Contributor

@patriciareinoso please rebase your PR. Thanks!

…nto add-swagger-ui

Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
@gab-arrobo gab-arrobo merged commit ec9874f into omec-project:master Aug 12, 2024
8 checks passed
@patriciareinoso patriciareinoso deleted the add-swagger-ui branch August 13, 2024 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants