[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

OpenShift API docs



We've just recently added support for visualizing the OpenShift API in order to build clients against the server.  Kubernetes added support for Swagger (www.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 --pvileged openshift/origin start --cors-allowed-origins=.*

Note the "--cors-allowed-origins=.*" argument, which allows JavaScript to use the server - this will be important in the last step.

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

    http://openshift3swagger-claytondev.rhcloud.com

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.

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.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]