forked from microsoft/typespec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocumentation.test.ts
41 lines (37 loc) · 1.23 KB
/
documentation.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { deepStrictEqual, strictEqual } from "assert";
import { describe, it } from "vitest";
import { openApiFor } from "./test-host.js";
describe("openapi3: documentation", () => {
it("supports summary and description", async () => {
const openApi = await openApiFor(`
@summary("This is a summary")
@doc("This is the longer description")
op read(): {};
`);
strictEqual(openApi.paths["/"].get.summary, "This is a summary");
strictEqual(openApi.paths["/"].get.description, "This is the longer description");
});
it("supports externalDocs on operation", async () => {
const openApi = await openApiFor(`
@externalDocs("https://example.com", "more info")
op read(): {};
`);
deepStrictEqual(openApi.paths["/"].get.externalDocs, {
url: "https://example.com",
description: "more info",
});
});
it("supports externalDocs on models", async () => {
const openApi = await openApiFor(`
op read(): Foo;
@externalDocs("https://example.com", "more info")
model Foo {
name: string;
}
`);
deepStrictEqual(openApi.components.schemas.Foo.externalDocs, {
url: "https://example.com",
description: "more info",
});
});
});