Skip to content

Latest commit

 

History

History

vpro-shared-swagger3

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Swagger utilities, and OpenAPI

This contains a few utility methods to deal with swagger.

Swagger frontend

It has a dependency on a webjars for swagger frontend itself, and supplies a simply taglib to wire that into the actual HTML.

E.g. our index page is normally implemented something like so:

<jsp:root
        xmlns:jsp="http://java.sun.com/JSP/Page"
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:swagger="https://www.vpro.nl/shared/tags/swagger"
        xmlns:npo="https://www.vpro.nl/shared/tags/npo"
        version="2.0">
  <jsp:directive.page contentType="text/html" pageEncoding="UTF-8" session="false" />
  <swagger:html
    title="Pages Publisher Swagger UI"
    deepLinking="true"
    filter="true"
    operationsSorter="alpha">
  >
    <jsp:attribute name="head">
      <npo:favicon />
    </jsp:attribute>
    <a href="https://wiki.vpro.nl/display/npoapi/Indexing">
      <npo:logo />
    </a>
  </swagger:html>
</jsp:root>

Open API Generation

The class nl.vpro.swagger.OpenAPIApplication is a wrapper around io.swagger.v3.core.util.Json which can be used to generate the openapi.json from java annotated rest-classes.

It has some spring configuration properties to:

  • fill in documentation urls

  • make replacements in documentation urls

  • set the version

Swagger filter

There is also provided a http filter nl.vpro.swagger.SwaggerFilter which main goal is to set the url of the current server, based on the current request.