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

Exposing Swagger File through Executor and providing Swagger UI through endpoint #1730

Merged
merged 11 commits into from
Apr 24, 2020
3 changes: 3 additions & 0 deletions executor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o executor
FROM gcr.io/distroless/static:latest
WORKDIR /
COPY --from=builder /workspace/executor .
# Copy openapi spec and swagger UI files
COPY ../openapi/swagger-ui/ /workspace/api/rest/openapi/
COPY ../openapi/seldon.json /workspace/api/rest/openapi/seldon.json
adriangonz marked this conversation as resolved.
Show resolved Hide resolved
COPY licenses/license.txt .
ENTRYPOINT ["/executor"]
2 changes: 2 additions & 0 deletions executor/api/rest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,13 @@ func (r *SeldonRestApi) Initialise() {
api01.Handle("/predictions", r.wrapMetrics(metric.PredictionHttpServiceName, r.predictions))
r.Router.NewRoute().Path("/api/v0.1/status/{" + ModelHttpPathVariable + "}").Methods("GET").HandlerFunc(r.wrapMetrics(metric.StatusHttpServiceName, r.status))
r.Router.NewRoute().Path("/api/v0.1/metadata/{" + ModelHttpPathVariable + "}").Methods("GET").HandlerFunc(r.wrapMetrics(metric.StatusHttpServiceName, r.metadata))
r.Router.NewRoute().PathPrefix("/api/v0.1/doc/").Handler(http.StripPrefix("/api/v0.1/doc/", http.FileServer(http.Dir("./openapi/v1.0/dist/"))))
adriangonz marked this conversation as resolved.
Show resolved Hide resolved
//v1.0 API
api1 := r.Router.PathPrefix("/api/v1.0").Methods("POST").Subrouter()
api1.Handle("/predictions", r.wrapMetrics(metric.PredictionServiceMetricName, r.predictions))
r.Router.NewRoute().Path("/api/v1.0/status/{" + ModelHttpPathVariable + "}").Methods("GET").HandlerFunc(r.wrapMetrics(metric.StatusHttpServiceName, r.status))
r.Router.NewRoute().Path("/api/v1.0/metadata/{" + ModelHttpPathVariable + "}").Methods("GET").HandlerFunc(r.wrapMetrics(metric.StatusHttpServiceName, r.metadata))
r.Router.NewRoute().PathPrefix("/api/v1.0/doc/").Handler(http.StripPrefix("/api/v1.0/doc/", http.FileServer(http.Dir("./openapi/v1.0/dist/"))))
adriangonz marked this conversation as resolved.
Show resolved Hide resolved

case api.ProtocolTensorflow:
r.Router.NewRoute().Path("/v1/models/{" + ModelHttpPathVariable + "}/:predict").Methods("POST").HandlerFunc(r.wrapMetrics(metric.PredictionHttpServiceName, r.predictions))
Expand Down
84 changes: 84 additions & 0 deletions openapi/swagger-ui/swagger_ui_bundled.html

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions openapi/swagger-ui/swagger_ui_cdn.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.24.2/swagger-ui.css" >
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}

*,
*:before,
*:after
{
box-sizing: inherit;
}

body
{
margin:0;
background: #fafafa;
}
</style>
</head>

<body>
<div id="swagger-ui"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.24.2/swagger-ui-bundle.js"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.24.2/swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "./seldon.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
// End Swagger UI call region

window.ui = ui
}
</script>
</body>
</html>