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
6 changes: 3 additions & 3 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ export function normalizeSwagger(parsedSpec) {
else if (inheritName === 'parameters') {
for (const param of inherits[inheritName]) {
const exists = operation[inheritName].some((opParam) => {
// check for `opParam.name` in case the parameter has
// no name, which is important for $ref'd parameters
return opParam.name && opParam.name === param.name
return (opParam.name && opParam.name === param.name)
|| (opParam.$ref && opParam.$ref === param.$ref)
|| (opParam.$$ref && opParam.$$ref === param.$$ref)
})

if (!exists) {
Expand Down
122 changes: 122 additions & 0 deletions test/bugs/ui-4466.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// https://github.com/swagger-api/swagger-ui/issues/4466
// https://github.com/swagger-api/swagger-ui/issues/4467

import expect, {createSpy, spyOn} from 'expect'
import resolveSubtree from '../../src/subtree-resolver'

const spec = {
swagger: '2.0',
info: {
version: 'v1',
title: 'Foo'
},
basePath: '/v1/foo',
produces: [
'application/json'
],
parameters: {
testHeader: {
name: 'test-header',
description: 'some request header',
type: 'string',
in: 'header',
required: false
}
},
paths: {
'/': {
parameters: [
{
$ref: '#/parameters/testHeader'
}
],
get: {
responses: {
200: {
description: 'Successful response',
schema: {
type: 'object',
properties: {
bar: {
type: 'string'
}
}
}
}
}
}
}
}
}


it('should resolve test case from UI-4466 and UI-4467 correctly', async function () {
const res = await resolveSubtree(spec, [])

expect(res).toEqual({
errors: [],
spec: {
swagger: '2.0',
$$normalized: true,
basePath: '/v1/foo',
info: {
title: 'Foo',
version: 'v1',
},
parameters: {
testHeader: {
description: 'some request header',
in: 'header',
name: 'test-header',
required: false,
type: 'string',
},
},
paths: {
'/': {
get: {
parameters: [
{
$$ref: '#/parameters/testHeader',
description: 'some request header',
in: 'header',
name: 'test-header',
required: false,
type: 'string',
},
],
produces: [
'application/json',
],
responses: {
200: {
description: 'Successful response',
schema: {
properties: {
bar: {
type: 'string',
},
},
type: 'object',
},
},
},
},
parameters: [
{
$$ref: '#/parameters/testHeader',
description: 'some request header',
in: 'header',
name: 'test-header',
required: false,
type: 'string',
},
],
},
},
produces: [
'application/json',
]
}
})
})