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-parameters.ts

26lines · modecode

1import { deepStrictEqual, strictEqual } from "assert";
2import { openApiFor } from "./test-host.js";
3
4describe("openapi3: parameters", () => {
5 it("create a query param", async () => {
6 const res = await openApiFor(
7 `
8 op test(@query arg1: string): void;
9 `
10 );
11 strictEqual(res.paths["/"].get.parameters[0].in, "query");
12 strictEqual(res.paths["/"].get.parameters[0].name, "arg1");
13 deepStrictEqual(res.paths["/"].get.parameters[0].schema, { type: "string" });
14 });
15
16 // Regression test for https://github.com/microsoft/cadl/issues/414
17 it("@doc set the description on the parameter not its schema", async () => {
18 const res = await openApiFor(
19 `
20 op test(@query @doc("mydoc") arg1: string): void;
21 `
22 );
23 strictEqual(res.paths["/"].get.parameters[0].description, "mydoc");
24 strictEqual(res.paths["/"].get.parameters[0].schema.description, undefined);
25 });
26});
27