Skip to content

Commit 943f709

Browse files
test(openapi-generator): add test cases for tags following the example
1 parent 9da14c6 commit 943f709

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

packages/openapi-generator/test/jsdoc.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,49 @@ test('parameter with a comment and an invalid example array', () => {
276276
message: '@example contains invalid JSON',
277277
});
278278
});
279+
280+
test('parameter with a comment, an example object and a tag', () => {
281+
const comment = `
282+
/**
283+
* A variable with example
284+
*
285+
* @example { "test": "foo" }
286+
* @tag api.example.test
287+
*/
288+
`;
289+
290+
const expected: JSDoc = {
291+
summary: 'A variable with example',
292+
// @ts-expect-error parser doesn't properly infer type
293+
tags: {
294+
example: { test: 'foo' },
295+
tag: 'api.example.test',
296+
},
297+
};
298+
299+
assert.deepEqual(parseJSDoc(comment), expected);
300+
});
301+
302+
test('parameter with a comment, an example object (multi-line) and a tag', () => {
303+
const comment = `
304+
/**
305+
* A variable with example
306+
*
307+
* @example {
308+
* "test": "foo"
309+
* }
310+
* @tag api.example.test
311+
*/
312+
`;
313+
314+
const expected: JSDoc = {
315+
summary: 'A variable with example',
316+
// @ts-expect-error parser doesn't properly infer type
317+
tags: {
318+
example: { test: 'foo' },
319+
tag: 'api.example.test',
320+
},
321+
};
322+
323+
assert.deepEqual(parseJSDoc(comment), expected);
324+
});

0 commit comments

Comments
 (0)