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

Re: OpenShift API docs





> On Dec 23, 2014, at 2:41 PM, Luke Meyer <lmeyer redhat com> wrote:
> 
> 
> 
> ----- Original Message -----
>> From: "Clayton Coleman" <ccoleman redhat com>
>> To: "OpenShift Development" <dev lists openshift redhat com>
>> Sent: Thursday, December 18, 2014 1:36:18 PM
>> Subject: 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
> 
> [typo] --privileged of course
> 
>>    --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
> 
> https://openshift3swagger-claytondev.rhcloud.com/ (the secure address) will also work, if you coerce your browser to allow it to load JS from (non-secure) localhost. Under Firefox and Chrome there is a small "shield" icon in the url bar to let you know it has blocked something which you can click to unblock it. Allowing a potential MITM to do arbitrary things with a REST API running in a privileged container on your host... strikes me as unwise. At least with https it's only Clayton we need to be paranoid of :)

True - and 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 alsorecreate 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 :)

> 
>> 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.
> 
> Pretty cool :)
> 
>> 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.
>> 
>> _______________________________________________
>> dev mailing list
>> dev lists openshift redhat com
>> http://lists.openshift.redhat.com/openshiftmm/listinfo/dev
>> 


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