Apereo CAS Swag with Swagger

Posted by Misagh Moayyed on July 24, 2018 · 2 mins read ·
Content Unavailable
Your browser is blocking content on this website. Please check your browser settings and try again.
This blog post was originally posted on Apereo GitHub Blog.

For some time now, CAS has had the ability to take advantages of Swagger natively to produce API documentation automatically. The generated documentation supports all CAS endpoints and REST APIs provided they are made available to the runtime application context. This means that any and all modules that declare API endpoints will automatically be recognized by the CAS Swagger integration, provided of course the module is activated and included in your CAS configuration.

If you wish to learn more about Swagger, please visit this link and the reference documentation for CAS 5.3.x as of this writing is available here.

Our starting position is based on the following:

Configuration

The setup is in fact super simple; as the documentation describes you simply need to add the required dependency in your overlay:

<dependency>
  <groupId>org.apereo.cas</groupId>
  <artifactId>cas-server-documentation-swagger</artifactId>
  <version>${cas.version}</version>
</dependency>

…and just to keep things more interesting, I also chose to include support for CAS REST Protocol:

<dependency>
    <groupId>org.apereo.cas</groupId>
    <artifactId>cas-server-support-rest</artifactId>
    <version>${cas.version}</version>
</dependency>

That’s it. Package and run the overlay as usual. Once the server is up and running, simply navigate to https://<your-cas-server-address>/cas/swagger-ui.html and examine the APIs presented to you via Swagger. For instance, this is what I see:

image

Notice how certain entries are surrounded in a blue square. This is not a Swagger feature; rather this is me trying to outline that the endpoints and APIs that are presented as part of the CAS protocol are also automatically picked up by Swagger and presented to you beautifully via this user interface. This behavior, as a reminder, applies to any module that presents APIs.

Finale

I hope this review was of some help to you and I am sure that both this post as well as the functionality it attempts to explain can be improved in any number of ways. Please feel free to engage and contribute as best as you can.

Misagh Moayyed