Skip to content

building an oas3BaseUrl fails if servers == [] #1307

@dtkav

Description

@dtkav

environment:

swagger-js version: v3.8.0

test case:

const spec = {
  openapi: '3.0.0',
  servers: []
}

const res = baseUrl({
  spec,  
  server: 'http://some-invalid-server.com/',
  contextUrl: 'http://google.com/'
})

expect(res).toEqual('http://google.com')

error:

  1) buildRequest - OpenAPI Specification 3.0 baseUrl should fall back to contextUrls if servers list is empty:
     TypeError: Cannot read property 'url' of undefined
      at oas3BaseUrl (src/execute/index.js:284:25)
      at baseUrl (src/execute/index.js:261:23)
      at Context.<anonymous> (test/oas3/execute/main.js:799:19)

potential fix:

dtkav@ca2a112

how I found the bug:

swagger-api/swagger-ui#4505

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions