Skip to content
Merged
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
5 changes: 3 additions & 2 deletions src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import isObject from 'lodash/isObject'
import startsWith from 'lodash/startsWith'

const toLower = str => String.prototype.toLowerCase.call(str)
const escapeString = (str) => {
Expand All @@ -12,7 +13,7 @@ export function isOAS3(spec) {
return false
}

return oasVersion.startsWith('3.0.0')
return startsWith(oasVersion, '3')
}

export function isSwagger2(spec) {
Expand All @@ -21,7 +22,7 @@ export function isSwagger2(spec) {
return false
}

return swaggerVersion.startsWith('2')
return startsWith(swaggerVersion, '2')
}

// Strategy for determining operationId
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import cloneDeep from 'lodash/cloneDeep'
import assign from 'lodash/assign'
import startsWith from 'lodash/startsWith'
import Url from 'url'
import Http, {makeHttp, serializeRes, serializeHeaders} from './http'
import Resolver, {clearCache} from './resolver'
Expand Down Expand Up @@ -82,7 +83,7 @@ Swagger.prototype.applyDefaults = function () {
const spec = this.spec
const specUrl = this.url
// TODO: OAS3: support servers here
if (specUrl && specUrl.startsWith('http')) {
if (specUrl && startsWith(specUrl, 'http')) {
const parsed = Url.parse(specUrl)
if (!spec.host) {
spec.host = parsed.host
Expand Down