Search results

Step 8: The externalDocs object (OpenAPI tutorial)

Keep current with the latest trends in technical communication by subscribing to the I'd Rather Be Writing newsletter. 5,000+ subscribers

I'm giving an API documentation workshop in San Francisco, California, on November 19, 2019. Check it out on EventBrite and register today to receive a $100 early bird discount.

The externalDocs object lets you link to external documentation. You can also provide links to external docs in the paths object.

Example externalDocs object

Here’s an example of an externalDocs object:

  description: API Documentation

Note that this documentation should relate to the API as a whole. To link a specific parameter to more documentation, you can add an externalDocs object to the operation object, as noted in Operation objects section in Step 4: The paths object.

View the Appearance in Swagger UI

Add the above code to the root level of your OpenAPI document in Swagger UI.

When you do, in the Swagger UI, a link appears after the API description along with other info about the API:

External documentation link
External documentation link

At this point, you can probably anticipate some challenges with integrating Swagger UI with the rest of your documentation. It seems that you will likely have two outputs and a semi-fragmented user experience. The externalDocs object at least gives you a predictable place to link back to your other conceptual topics. See Integrating Swagger UI with the rest of your docs for more information on integration strategies.

Seeing the finished result

Now that we’ve completed all the steps in the tutorial, we’re finished building our OpenAPI specification document. You can see the complete specification document here:

Here’s the specification document rendered by Swagger UI:

Try executing a request in the version above and look at the result. In the result, locate the temp value in the main object. Then take a break by going outside and evaluate whether the temperature outside matches the response.

You can insert any valid path to an OpenAPI specification document in the “Explore” box in Swagger UI (assuming the version of Swagger UI supports your OpenAPI version), and it will display the API documentation. For example, you could insert (then click Explore) and it would show the Petstore API.

71% Complete

71/146 pages complete. Only 75 more pages to go.


Want to buy me lunch? Click the Donate button below to donate any amount through Paypal.