microsoft/typespec
Publicmirrored from https://github.com/microsoft/typespecAvailable
packages/openapi3/test/test-parameters.ts
26lines · modecode
| 1 | import { deepStrictEqual, strictEqual } from "assert"; |
| 2 | import { openApiFor } from "./test-host.js"; |
| 3 | |
| 4 | describe("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 | |