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

disable swagger UI docs in non-dev environments #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ A REST API to execute [teuthology commands](https://docs.ceph.com/projects/teuth
volumes:
- ../../../teuthology-api:/teuthology_api/:rw
```
`DEPLOYMENT: development` would run the server in `--reload` mode (server would restart when changes are made in `/src` dir) and `volumes` would mount host directory to docker's directory (local changes would reflect in docker container).
`DEPLOYMENT: development` would:
1) run the server in `--reload` mode (server would restart when changes are made in `/src` dir),
2) `volumes` would mount host directory to docker's directory (local changes would reflect in docker container),
3) start Swagger UI interactive docs at `/docs` endpoint.

5. Follow teuthology development setup instructions from [here](https://github.com/ceph/teuthology/tree/main/docs/docker-compose).

Expand All @@ -64,7 +67,7 @@ A REST API to execute [teuthology commands](https://docs.ceph.com/projects/teuth

## Documentation

The documentation can be accessed at http://localhost:8082/docs after running the application.
The documentation can be accessed at http://localhost:8082/docs after running the application (with environment variable `DEPLOYMENT` set as `"development"`).

Note: To run commands, authenticate by visiting `http://localhost:8082/login` through browser and follow the github authentication steps (this stores the auth token in browser cookies).

Expand Down
10 changes: 9 additions & 1 deletion src/teuthology_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
PADDLES_URL = os.getenv("PADDLES_URL")

log = logging.getLogger(__name__)
app = FastAPI()


app_config = {}
if DEPLOYMENT == "development":
app_config["docs_url"] = "/docs"
else:
app_config["docs_url"] = None

app = FastAPI(**app_config)


@app.get("/")
Expand Down
Loading