PaloAltoNetworks / docusaurus-openapi-docs

🦝 OpenAPI plugin for generating API reference docs in Docusaurus v3.
https://docusaurus-openapi.tryingpan.dev
MIT License
701 stars 234 forks source link

[Bug] Multiline descriptions result in invalid frontmatter #324

Closed sserrata closed 2 years ago

sserrata commented 2 years ago

Describe the bug

Some info and operation descriptions contain multiline strings. Mustache templating doesn't appear to support indenting multiline strings which limits our ability to handle these properly.

This is how we would want to handle them:

description: |
    This is
    my
    multiline string

But, this is not supported or, at least, it results in only the first line being indented:

description: |
    {{{my_multiline_string_var}}}

Expected behavior

Mustache templating should apply indenting to entire multiline string.

Current behavior

Mustache templating only applies indenting/spacing to first line in multiline string.

Multiline descriptions result in the following error:

[ERROR] Error while parsing Markdown front matter.
This can happen if you use special characters in front matter values (try using double quotes around that value).

Possible solution

Since this affects frontmatter only, one idea would be to "split lines" the description and take only the first line as the frontmatter description. The rationale is that it would ostensibly be used primarily for social previews and for descriptions in search engine results. Also, the full description would still be included/rendered in the API doc itself.

Steps to reproduce

Reproduced using the CSPM product API.

Note: this error surfaced after the #320 fix was applied.

sserrata commented 2 years ago

Results of first test:

Screen Shot 2022-11-04 at 10 14 17 AM
sserrata commented 2 years ago

More elaborate example (notice only first line ends up in meta description):

Screen Shot 2022-11-04 at 10 15 08 AM