diff --git a/src/server/dispatcher.ts b/src/server/dispatcher.ts index e212a31e..af8174d7 100644 --- a/src/server/dispatcher.ts +++ b/src/server/dispatcher.ts @@ -84,7 +84,7 @@ export class Dispatcher { } for (const parameter of parameters) { - const type = parameter.schema?.type ?? parameter?.type; + const type = parameter?.type; if (type !== undefined) { types[parameter.in][parameter.name] = diff --git a/test/server/dispatcher.test.ts b/test/server/dispatcher.test.ts index 3f5c5d52..74780346 100644 --- a/test/server/dispatcher.test.ts +++ b/test/server/dispatcher.test.ts @@ -562,112 +562,6 @@ describe("a dispatcher", () => { it("converts query, path, and header parameters to numbers if necessary", async () => { const registry = new Registry(); - registry.add("/a/{integerInPath}/{stringInPath}", { - // @ts-expect-error - not obvious how to make TS happy here, and it's just a unit test - GET({ headers, path, query, response }) { - if (path === undefined) { - throw new Error("path is undefined"); - } - - return response["200"]?.text({ - integerInPath: path.integerInPath, - numberInHeader: headers.numberInHeader, - numberInQuery: query.numberInQuery, - stringInHeader: headers.stringInHeader, - stringInPath: path.stringInPath, - stringInQuery: query.stringInQuery, - }); - }, - }); - - const openApiDocument: OpenApiDocument = { - paths: { - "/a/{integerInPath}/{stringInPath}": { - get: { - parameters: [ - { - in: "path", - name: "integerInPath", - schema: { type: "integer" }, - }, - { in: "path", name: "stringInPath", schema: { type: "string" } }, - { - in: "query", - name: "numberInQuery", - schema: { type: "number" }, - }, - { - in: "query", - name: "stringInQuery", - schema: { type: "string" }, - }, - { - in: "header", - name: "numberInHeader", - schema: { type: "number" }, - }, - { - in: "header", - name: "stringInHeader", - schema: { type: "string" }, - }, - ], - - responses: { - 200: { - content: { - "application/json": { - schema: { - integerInPath: "number", - stringInPath: "string", - }, - }, - }, - }, - }, - }, - }, - }, - }; - - const dispatcher = new Dispatcher( - registry, - new ContextRegistry(), - openApiDocument, - ); - const htmlResponse = await dispatcher.request({ - body: "", - - headers: { - numberInHeader: "5", - stringInHeader: "6", - }, - - method: "GET", - - path: "/a/1/2", - - query: { - numberInQuery: "3", - stringInQuery: "4", - }, - - req: { path: "/a/1/2" }, - }); - - expect(htmlResponse.body).toStrictEqual({ - integerInPath: 1, - numberInHeader: 5, - numberInQuery: 3, - stringInHeader: "6", - stringInPath: "2", - stringInQuery: "4", - }); - }); - - it("converts query, path, and header parameters to numbers if necessary (Swagger v2)", async () => { - const registry = new Registry(); - registry.add("/a/{integerInPath}/{stringInPath}", { // @ts-expect-error - not obvious how to make TS happy here, and it's just a unit test GET({ headers, path, query, response }) {