microsoft/typespec

Public

mirrored from https://github.com/microsoft/typespecAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
e966efd30e552f4e84d5ae7224515199738ddd8e

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

packages/openapi3/test/test-documentation.ts

49lines · modecode

1import { deepStrictEqual, strictEqual } from "assert";
2import { openApiFor } from "./test-host.js";
3
4describe("openapi3: documentation", () => {
5 it("supports summary and description", async () => {
6 const openApi = await openApiFor(`
7 @route("/")
8 namespace N {
9 @summary("This is a summary")
10 @doc("This is the longer description")
11 op read(): {};
12 }
13 `);
14 strictEqual(openApi.paths["/"].get.summary, "This is a summary");
15 strictEqual(openApi.paths["/"].get.description, "This is the longer description");
16 });
17
18 it("supports externalDocs on operation", async () => {
19 const openApi = await openApiFor(`
20 @route("/")
21 namespace N {
22 @externalDocs("https://example.com", "more info")
23 op read(): {};
24 }
25 `);
26 deepStrictEqual(openApi.paths["/"].get.externalDocs, {
27 url: "https://example.com",
28 description: "more info",
29 });
30 });
31
32 it("supports externalDocs on models", async () => {
33 const openApi = await openApiFor(`
34 @route("/")
35 namespace N {
36 op read(): Foo;
37 }
38
39 @externalDocs("https://example.com", "more info")
40 model Foo {
41 name: string;
42 }
43 `);
44 deepStrictEqual(openApi.components.schemas.Foo.externalDocs, {
45 url: "https://example.com",
46 description: "more info",
47 });
48 });
49});
50