Skip to content

Commit 0509c5a

Browse files
authored
fix: use forward compatible OpenAPI version detection (#2886)
This detection is also aligned with ApiDOM version detection.
1 parent d6a7d2f commit 0509c5a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/helpers/openapi-predicates.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const isOpenAPI2 = (spec) => {
99
export const isOpenAPI30 = (spec) => {
1010
try {
1111
const { openapi } = spec;
12-
return typeof openapi === 'string' && openapi.startsWith('3.0');
12+
return typeof openapi === 'string' && /^3\.0\.([0123])(?:-rc[012])?$/.test(openapi);
1313
} catch {
1414
return false;
1515
}
@@ -18,7 +18,7 @@ export const isOpenAPI30 = (spec) => {
1818
export const isOpenAPI31 = (spec) => {
1919
try {
2020
const { openapi } = spec;
21-
return typeof openapi === 'string' && openapi.startsWith('3.1');
21+
return typeof openapi === 'string' && /^3\.1\.(?:[1-9]\d*|0)$/.test(openapi);
2222
} catch {
2323
return false;
2424
}

0 commit comments

Comments
 (0)