microsoft/typespec

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
bd60b0a68bb23817a01ab4aef22170c18abd81ed

Branches

Tags

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

Clone

HTTPS

Download ZIP

packages/openapi3/test/documentation.test.ts

40lines · 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 @summary("This is a summary")
8 @doc("This is the longer description")
9 op read(): {};
10 `);
11 strictEqual(openApi.paths["/"].get.summary, "This is a summary");
12 strictEqual(openApi.paths["/"].get.description, "This is the longer description");
13 });
14
15 it("supports externalDocs on operation", async () => {
16 const openApi = await openApiFor(`
17 @externalDocs("https://example.com", "more info")
18 op read(): {};
19 `);
20 deepStrictEqual(openApi.paths["/"].get.externalDocs, {
21 url: "https://example.com",
22 description: "more info",
23 });
24 });
25
26 it("supports externalDocs on models", async () => {
27 const openApi = await openApiFor(`
28 op read(): Foo;
29
30 @externalDocs("https://example.com", "more info")
31 model Foo {
32 name: string;
33 }
34 `);
35 deepStrictEqual(openApi.components.schemas.Foo.externalDocs, {
36 url: "https://example.com",
37 description: "more info",
38 });
39 });
40});
41