-
Notifications
You must be signed in to change notification settings - Fork 837
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from cliveseldon/openapi
Add Open API Definitions
- Loading branch information
Showing
33 changed files
with
2,216 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
api-frontend/src/main/java/io/seldon/apife/config/SimpleCorsFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.seldon.apife.config; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.servlet.Filter; | ||
import javax.servlet.FilterChain; | ||
import javax.servlet.FilterConfig; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.ServletRequest; | ||
import javax.servlet.ServletResponse; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.springframework.core.Ordered; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Order(Ordered.HIGHEST_PRECEDENCE) | ||
public class SimpleCorsFilter implements Filter { | ||
|
||
public SimpleCorsFilter() { | ||
} | ||
|
||
@Override | ||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { | ||
HttpServletResponse response = (HttpServletResponse) res; | ||
HttpServletRequest request = (HttpServletRequest) req; | ||
response.setHeader("Access-Control-Allow-Origin", "*"); | ||
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); | ||
response.setHeader("Access-Control-Max-Age", "3600"); | ||
//response.setHeader("Access-Control-Allow-Headers", "x-requested-with, authorization"); | ||
response.setHeader("Access-Control-Allow-Headers", "API-Key, accept, Content-Type, x-requested-with, authorization"); | ||
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) { | ||
response.setStatus(HttpServletResponse.SC_OK); | ||
} else { | ||
chain.doFilter(req, res); | ||
} | ||
} | ||
|
||
@Override | ||
public void init(FilterConfig filterConfig) { | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
|
||
# Creates a base swagger definition | ||
seldon.grpcapi.swagger.json: | ||
protoc -I/usr/local/include -I. -I${GOPATH}/src -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway --swagger_out=logtostderr=true:. prediction.grpcapi.proto | ||
|
||
engine.oa3.json apife.oa3.josn component.oa3.json: | ||
python create_openapis.py | ||
|
||
clean: | ||
rm -f engine.oa3.json | ||
rm -f apife.oa3.josn | ||
rm -f component.oa3.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Open API V3 for Seldon Core API | ||
|
||
We provide initial [OpenAPI](https://www.openapis.org/) 3.0 specifications for our APIs | ||
|
||
* [Seldon Core External via Ambassador](engine.oas3.json) | ||
* [Seldon Core External via API Gateway](apife.oas3.json) | ||
* [Seldon Core Internal microservice API](wrapper.oas3.json) | ||
|
||
You will find the API Specs at runtime at the ```/seldon.json``` path of your API endpoint. | ||
|
||
You will need to be running 0.2.4-SNAPSHOT or later for this endpoint to be active. | ||
|
||
## Viewing/Testing via Swagger-UI | ||
|
||
You can view the APIs using the [Swagger UI tool](https://swagger.io/tools/swagger-ui/). | ||
|
||
You can run this via Docker with: | ||
|
||
``` | ||
docker run --network host --rm swaggerapi/swagger-editor | ||
``` | ||
|
||
It will be reachable at http://localhost:8080/ | ||
|
||
 | ||
|
||
For using the Swagger "try it out" feature there are some caveats due to Swagger UI bugs: | ||
|
||
* For the [Seldon Core External via API Gateway](apife.oas3.json) | ||
* You will need to use a hardwired host, localhost:8002 is provided for Authorization as currently the Swagger UI can't handle variables in Authorization calls. | ||
* You will need to use the browser network console to get the bearer token from the returned json as this is not displayed by the Swagger UI. | ||
* For the [Seldon Internal API](wrapper.oas3.json) | ||
* in GET calls you can't edit the JSON string passed. | ||
|
||
|
||
## Contributions and Roadmap | ||
|
||
We welcome contributions to improving these initial API specifications. | ||
|
||
We plan to investigate how these APIs can be customized to show the acceptable payloads for a particular machine learning inference graph running under Seldon Core. Suggestions welcome. | ||
|
||
|
Oops, something went wrong.