From 355764dcd484d3bea8f16e7c8a10eb0775b896f4 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 27 Sep 2018 10:20:01 +0300 Subject: [PATCH] fix: server overriding didn't work on Path Item object fixes #656 --- src/services/models/Operation.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/services/models/Operation.ts b/src/services/models/Operation.ts index a63fa776..bd12a064 100644 --- a/src/services/models/Operation.ts +++ b/src/services/models/Operation.ts @@ -4,7 +4,12 @@ import { IMenuItem } from '../MenuStore'; import { GroupModel } from './Group.model'; import { SecurityRequirementModel } from './SecurityRequirement'; -import { OpenAPIExternalDocumentation, OpenAPIServer, OpenAPIXCodeSample } from '../../types'; +import { + OpenAPIExternalDocumentation, + OpenAPIPath, + OpenAPIServer, + OpenAPIXCodeSample, +} from '../../types'; import { getOperationSummary, @@ -83,9 +88,14 @@ export class OperationModel implements IMenuItem { this.operationId = operationSpec.operationId; this.codeSamples = operationSpec['x-code-samples'] || []; this.path = operationSpec.pathName; + + const pathInfo = parser.byRef( + JsonPointer.compile(['paths', operationSpec.pathName]), + ); + this.servers = normalizeServers( parser.specUrl, - operationSpec.servers || parser.spec.servers || [], + operationSpec.servers || (pathInfo && pathInfo.servers) || parser.spec.servers || [], ); this.security = (operationSpec.security || parser.spec.security || []).map(