Skip to content

Commit

Permalink
(bug) putting back missing 'required: true' from path parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
eropple committed Sep 24, 2024
1 parent 9101303 commit e044848
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export const oas3Plugin = fastifyPlugin<OAS3PluginOptions>(
paramExtra.description ??
paramValue.description ??
"No path parameter description specified.",
required: true,
example: paramExtra.example ?? paramValue.example,
schema: paramExtra.schemaOverride ?? paramValue,
});
Expand Down
14 changes: 12 additions & 2 deletions test/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,18 @@ describe("plugin", () => {
const parameters = operation?.parameters;
// remember: `required` is implied (and forced true) for path params
expect(parameters).toMatchObject([
{ in: "path", name: "primary", schema: { type: "string" } },
{ in: "path", name: "secondary", schema: { type: "number" } },
{
in: "path",
name: "primary",
schema: { type: "string" },
required: true,
},
{
in: "path",
name: "secondary",
schema: { type: "number" },
required: true,
},
]);
});
});

0 comments on commit e044848

Please sign in to comment.