Skip to content

Commit

Permalink
fix: use forward compatible OpenAPI version detection (#2886)
Browse files Browse the repository at this point in the history
This detection is also aligned with ApiDOM version detection.
  • Loading branch information
char0n authored Mar 15, 2023
1 parent d6a7d2f commit 0509c5a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/helpers/openapi-predicates.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const isOpenAPI2 = (spec) => {
export const isOpenAPI30 = (spec) => {
try {
const { openapi } = spec;
return typeof openapi === 'string' && openapi.startsWith('3.0');
return typeof openapi === 'string' && /^3\.0\.([0123])(?:-rc[012])?$/.test(openapi);
} catch {
return false;
}
Expand All @@ -18,7 +18,7 @@ export const isOpenAPI30 = (spec) => {
export const isOpenAPI31 = (spec) => {
try {
const { openapi } = spec;
return typeof openapi === 'string' && openapi.startsWith('3.1');
return typeof openapi === 'string' && /^3\.1\.(?:[1-9]\d*|0)$/.test(openapi);
} catch {
return false;
}
Expand Down

0 comments on commit 0509c5a

Please sign in to comment.