source: node_modules/swagger-client/es/helpers/openapi-predicates.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 710 bytes
Line 
1export const isOpenAPI2 = spec => {
2 try {
3 const {
4 swagger
5 } = spec;
6 return swagger === '2.0';
7 } catch {
8 return false;
9 }
10};
11export const isOpenAPI30 = spec => {
12 try {
13 const {
14 openapi
15 } = spec;
16 return typeof openapi === 'string' && /^3\.0\.([0123])(?:-rc[012])?$/.test(openapi);
17 } catch {
18 return false;
19 }
20};
21export const isOpenAPI31 = spec => {
22 try {
23 const {
24 openapi
25 } = spec;
26 return typeof openapi === 'string' && /^3\.1\.(?:[1-9]\d*|0)$/.test(openapi);
27 } catch {
28 return false;
29 }
30};
31export const isOpenAPI3 = spec => isOpenAPI30(spec) || isOpenAPI31(spec);
32
33// backward compatibility export
34export { isOpenAPI2 as isSwagger2 };
Note: See TracBrowser for help on using the repository browser.