Skip to content

Commit

Permalink
Merge bbb39fb into b7c1c10
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanpm committed Jul 22, 2020
2 parents b7c1c10 + bbb39fb commit 403b168
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/openapi/*.json

# PyBuilder
target/
Expand Down
5 changes: 5 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"github_banner": True,
"description": "Publishing microservice for Red Hat's Content Delivery Network",
"extra_nav_links": {
"API": "api.html",
"Source": "https://github.com/release-engineering/exodus-gw",
"Index": "genindex.html",
},
Expand All @@ -106,6 +107,10 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

# This dir contains the generated openapi spec and the static redoc-based
# api.html for viewing. Copy it alongside the other docs.
html_extra_path = ["openapi"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
Expand Down
27 changes: 27 additions & 0 deletions docs/openapi/api.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>

<head>
<title>exodus-gw API</title>

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">

<!--
ReDoc doesn't change outer page styles
-->
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>

<body>
<redoc spec-url='openapi.json'></redoc>
<script src="https://cdn.jsdelivr.net/npm/redoc@2.0.0-rc.33/bundles/redoc.standalone.js"> </script>
</body>

</html>
6 changes: 6 additions & 0 deletions exodus_gw/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Any modules which add endpoints onto the app must be imported here
from . import gateway

# Per ASGI conventions, main entry point is accessible as "exodus_gw:application"
from .app import app as application

3 changes: 3 additions & 0 deletions exodus_gw/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fastapi import FastAPI

app = FastAPI(title="exodus-gw")
5 changes: 2 additions & 3 deletions exodus_gw/gateway.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from fastapi import FastAPI

app = FastAPI()
from .app import app


@app.get("/healthcheck")
def healthcheck():
"""Returns a successful response if the service is running."""
return {"200": "OK"}
12 changes: 12 additions & 0 deletions scripts/gen-openapi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python3
# Helper script to generate openapi JSON file
# during publishing of docs.
import os
import json

from exodus_gw import application

api = application.openapi()

with open("docs/openapi/openapi.json", "wt") as f:
json.dump(api, f)
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ deps=
use_develop=true
commands_pre=
commands=
python scripts/gen-openapi
sphinx-build -M html docs docs/_build

[pytest]
Expand Down

0 comments on commit 403b168

Please sign in to comment.