Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down
106 changes: 0 additions & 106 deletions test/server/dispatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down