We recently added support for visualizing the OpenShift API in order to build clients against the server. Kubernetes added support for Swagger.io API descriptions of their resources, and we’ve begun enabling that in OpenShift master.
To see the API docs, run OpenShift locally:
$ docker pull openshift/origin $ docker run -v /var/run/docker.sock:/var/run/docker.sock --net=host --privileged openshift/origin start --cors-allowed-origins=.*
The API documents are exposed in structured form at
# Root doc $ curl http://localhost:8080/swaggerapi # Kubernetes $ curl http://localhost:8080/swaggerapi/api/v1beta1 # OpenShift $ curl http://localhost:8080/swaggerapi/osapi/v1beta1
Since Swagger is a structured API description, you can use the Swagger UI to read the API description and visualize it. If you have OpenShift started locally, visit
where I’m running a copy of the hosted swagger UI pointing back to localhost. You should see “v1beta1” and some links – click “Expand Operations” to see all of the resources and calls we expose. To explore the Kubernetes API, paste “http://localhost:8080/swaggerapi/api/v1beta1” into the text box at the top of the page and hit explore.
For the security conscious, if you want to see the source and run it yourself with:
$ rhc create-app swaggerui php --from-source=https://github.com/smarterclayton/swagger-ui-site.git
You can also recreate the site by creating a repo with just the
*dist* folder from the main swagger UI project.
When we add auth soon you’ll be able to use an auth token via the UI (upper right input).
For further security, run this on a Mac without Docker installed.
Over the next few months Kubernetes and OpenShift will improve this to have a lot more information and better structure. Please use this as a resource when building clients. You can also use https://github.com/swagger-api/swagger-codegen to generate libraries for some common languages. I haven’t personally used it, but it’s worth investigating to save some effort.