Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Don't break TOC when OpenAPI description includes headers
As noted in [0], the ability to render a CommonMark document through OpenAPI specifications' `info.description` is breaking due to how the Table of Contents code works. We'd assumed that the `id` would always be set on headers - by Middleman - but as it's possible for an OpenAPI description to include headers, we won't always have one. Until the `openapi3_parser` gem supports making this configurable, which is unlikely, due to the way that CommonMark doesn't have this as a default extension, we can instead utilise our `TechDocsHTMLRenderer` to render the headings with IDs, as expected. To do this, we can create a new helper in `ApiReferenceRenderer` which will render the Markdown document as our custom Markdown, which requires we construct the `TechDocsHTMLRenderer` class, which needs the Middleman `ConfigContext` class injected in. This means that we won't be using CommonMark, as per the OpenAPI spec, and this is something we'll look to address in alphagov#282. [0]: alphagov/tdt-documentation#156
- Loading branch information