Skip to content

Conversation

@dtkav
Copy link
Contributor

@dtkav dtkav commented May 4, 2018

Description

According to: https://swagger.io/docs/specification/api-host-and-base-path/
If the server block doesn't exist, or is empty then it shall default to '/'
This seems to work for a missing servers block, but not for an empty list.

The old code attempted to access the first element in an array without checking if the list was empty.
This fix ensures that the array is not empty.

Motivation and Context

Fixes #1307

How Has This Been Tested?

I tested that the change fixes the following bug in swagger-ui swagger-api/swagger-ui#4505
I used this spec to trigger the failure.
I also added a new unit test to cover the change.

Screenshots (if appropriate):

n/a

Types of changes

  • No code changes (changes to documentation, CI, metadata, etc)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@shockey shockey merged commit 3d6bbdb into swagger-api:master May 8, 2018
@shockey
Copy link
Contributor

shockey commented May 8, 2018

thanks @dtkav!!

shockey pushed a commit to shockey/swagger-js that referenced this pull request Nov 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

building an oas3BaseUrl fails if servers == []

2 participants