Working with the /swagger.json endpoint

Each individual API can also serve up its own documentation using the /swagger.json API that the REST framework adds automatically to the API. A GET request to /apiBasePath/swagger.json returns the externalized, canonical Swagger JSON for that API, suitable for use with standard tools that understand Swagger 2.0 schemas.

For example, to access the Swagger schema for the list of published APIs, use the following URL:
  • http://localhost:8180/pc/rest/apis/swagger.json

Accessing this URL returns an HTML-formatted version of the Swagger schema for that API endpoint.

Automatic generation of /swagger.json

The Guidewire REST framework uses the API template mechanism to add the /swagger.json path to the REST APIs. In the base configuration, file published-apis.yaml defines the default template for the REST APIs:

  • gw.pl.framework.dev_template-1.0.swagger.yaml
File gw.pl.framework.dev_template-1.0 includes Swagger schema gw.pl.framework.api_docs-1.0.swagger.yaml, which automatically adds the following REST endpoint:
  • GET /swagger.json

It is possible to remove the /swagger.json endpoint from the list of published APIs by using a different default template.