Skip to content

Commit

Permalink
fix: empty servers behaviour per OAS spec
Browse files Browse the repository at this point in the history
fixes #1151
  • Loading branch information
RomanHotsiy committed Jan 10, 2020
1 parent a260c84 commit ed1db0c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Referenced,
} from '../types';
import { IS_BROWSER } from './dom';
import { isNumeric, removeQueryString, resolveUrl, stripTrailingSlash } from './helpers';
import { isNumeric, removeQueryString, resolveUrl } from './helpers';

function isWildcardStatusCode(statusCode: string | number): statusCode is string {
return typeof statusCode === 'string' && /\dxx/i.test(statusCode);
Expand Down Expand Up @@ -530,9 +530,10 @@ export function normalizeServers(
const baseUrl = specUrl === undefined ? removeQueryString(getHref()) : dirname(specUrl);

if (servers.length === 0) {
return [
// Behaviour defined in OpenAPI spec: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#openapi-object
servers = [
{
url: stripTrailingSlash(baseUrl),
url: '/',
},
];
}
Expand Down

0 comments on commit ed1db0c

Please sign in to comment.