Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: strip markdown from descriptions #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions __tests__/docs-description.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,58 @@ testRule("docs-description", [
},
],
},
{
name: "valid: description with markdown, properly formatted after stripping markdown",
document: {
openapi: "3.1.0",
info: {
description:
"**Bold** _Italic_ `code` is used to format _human-readable_ documentation that follows the rules.",
},
paths: {},
},
errors: [],
},

{
name: "invalid: description with markdown, but starts with a lowercase letter",
document: {
openapi: "3.1.0",
info: {
description:
"**bold** _Italic_ should start with a capital letter after removing markdown.",
},
paths: {},
},
errors: [
{
message:
'"**bold** _Italic_ should start with a capital letter after removing markdown." must match the pattern "/^[A-Z]/".',
path: ["info", "description"],
severity: DiagnosticSeverity.Warning,
},
],
},

{
name: "invalid: description with markdown, but missing full stop at the end",
document: {
openapi: "3.1.0",
info: {
description:
"Descriptions with **bold**, _italic_, and other markdown need a full stop at the end",
},
paths: {},
},
errors: [
{
message:
'"Descriptions with **bold**, _italic_, and other markdown need a full stop at the end" must match the pattern "\\\\.$".',
path: ["info", "description"],
severity: DiagnosticSeverity.Warning,
},
],
},

{
name: "does not throw on refs",
Expand Down
Loading
Loading