Skip to content
Closed
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
4 changes: 2 additions & 2 deletions lib/parser.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,8 +46,8 @@ export interface ParsedRoute {
export default async function parse(specOrPath: string | OpenAPIObject): Promise<ParsedConfig> {
const spec = await bundleSpecification(specOrPath); //await dereference(specOrPath);

if (!spec?.openapi?.startsWith("3.0")) {
throw new Error("The 'specification' parameter must contain a valid version 3.0.x specification");
if (!spec?.openapi?.startsWith("3.")) {
throw new Error("The 'specification' parameter must contain a valid version 3.x specification");
}

const $refs = await $RefParser.resolve(spec);
Expand Down
15 changes: 14 additions & 1 deletion tests/plugin-config.spec.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,7 +40,7 @@ describe("Config", () => {
await expect(fastify.ready())
.rejects.toHaveProperty(
"message",
"The 'specification' parameter must contain a valid version 3.0.x specification"
"The 'specification' parameter must contain a valid version 3.x specification"
);
});

Expand DownExpand Up@@ -78,4 +78,17 @@ describe("Config", () => {
await expect(fastify.ready())
.resolves.toBe(fastify);
});

test("should load V3.1.0 definition with no error", async () => {
const spec310 = JSON.parse(JSON.stringify(PETSTORE_SPEC));
spec310["openapi"] = "3.1.0";

const fastify = createFastify({
specification: spec310,
controller: CONTROLLER_FILE
});

await expect(fastify.ready())
.resolves.toBe(fastify);
});
});