improvement: handle more invalid Swagger/OpenAPI version values gracefully (#4699)
* improvement: handle more invalid version values gracefully * use source maps in Mocha tests yields accurate stack trace line numbers
This commit is contained in:
@@ -2,16 +2,20 @@ import React from "react"
|
||||
|
||||
export function isOAS3(jsSpec) {
|
||||
const oasVersion = jsSpec.get("openapi")
|
||||
if(!oasVersion) {
|
||||
if(typeof oasVersion !== "string") {
|
||||
return false
|
||||
}
|
||||
|
||||
return oasVersion.startsWith("3.0.")
|
||||
// we gate against `3.1` becasue we want to explicitly opt into supporting it
|
||||
// at some point in the future -- KS, 7/2018
|
||||
|
||||
// starts with, but is not `3.0.` exactly
|
||||
return oasVersion.startsWith("3.0.") && oasVersion.length > 4
|
||||
}
|
||||
|
||||
export function isSwagger2(jsSpec) {
|
||||
const swaggerVersion = jsSpec.get("swagger")
|
||||
if(!swaggerVersion) {
|
||||
if(typeof swaggerVersion !== "string") {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user