Skip to content

Commit 8dd2305

Browse files
committed
Merge branch 'master' of github.com:swagger-api/swagger-ui into ft/linting-and-testing
2 parents fa3afc0 + 19558e7 commit 8dd2305

File tree

5 files changed

+72
-8
lines changed

5 files changed

+72
-8
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ To help with the migration, here are the currently known issues with 3.X. This l
5454
- The JSON Form Editor is not implemented.
5555
- Shebang URL support for operations is missing.
5656
- Support for `collectionFormat` is partial.
57+
- l10n (translations) is not implemented.
58+
- Relative path support for external files is not implemented.
5759

5860

5961
## CORS Support

dist/swagger-ui-bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/swagger-ui-standalone-preset.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/plugins/samples/fn.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,12 @@ export const sampleXmlFromSchema = (schema, config={}) => {
127127

128128
if (xml.wrapped) {
129129
res[displayName] = []
130-
if (Array.isArray(defaultValue)) {
131-
130+
if (Array.isArray(example)) {
131+
example.forEach((v)=>{
132+
items.example = v
133+
res[displayName].push(sampleXmlFromSchema(items, config))
134+
})
135+
} else if (Array.isArray(defaultValue)) {
132136
defaultValue.forEach((v)=>{
133137
items.default = v
134138
res[displayName].push(sampleXmlFromSchema(items, config))
@@ -145,14 +149,20 @@ export const sampleXmlFromSchema = (schema, config={}) => {
145149

146150
let _res = []
147151

148-
if (Array.isArray(defaultValue)) {
152+
if (Array.isArray(example)) {
153+
example.forEach((v)=>{
154+
items.example = v
155+
_res.push(sampleXmlFromSchema(items, config))
156+
})
157+
return _res
158+
} else if (Array.isArray(defaultValue)) {
149159
defaultValue.forEach((v)=>{
150160
items.default = v
151161
_res.push(sampleXmlFromSchema(items, config))
152162
})
153163
return _res
154-
155164
}
165+
156166
return sampleXmlFromSchema(items, config)
157167
}
158168
}
@@ -176,7 +186,13 @@ export const sampleXmlFromSchema = (schema, config={}) => {
176186
} else {
177187
props[propName].xml.name = props[propName].xml.name || propName
178188
props[propName].example = props[propName].example !== undefined ? props[propName].example : example[propName]
179-
res[displayName].push(sampleXmlFromSchema(props[propName]))
189+
let t = sampleXmlFromSchema(props[propName])
190+
if (Array.isArray(t)) {
191+
res[displayName] = res[displayName].concat(t)
192+
} else {
193+
res[displayName].push(t)
194+
}
195+
180196
}
181197
}
182198
}

test/core/plugins/samples/fn.js

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ describe("createXMLExample", function () {
396396
})
397397

398398
it("returns array with default values with wrapped=true", function () {
399-
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<animals>\n\t<animal>one</animal>\n</animals>"
399+
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<animals>\n\t<animal>1</animal>\n\t<animal>2</animal>\n</animals>"
400400
var definition = {
401401
items: {
402402
"enum": ["one", "two"],
@@ -405,6 +405,7 @@ describe("createXMLExample", function () {
405405
name: "animal"
406406
}
407407
},
408+
"default": ["1", "2"],
408409
xml: {
409410
wrapped: true,
410411
name: "animals"
@@ -413,8 +414,53 @@ describe("createXMLExample", function () {
413414

414415
expect(sut(definition)).toEqual(expected)
415416
})
417+
418+
it("returns array with example values with ", function () {
419+
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<animals>\n\t<animal>1</animal>\n\t<animal>2</animal>\n</animals>"
420+
var definition = {
421+
type: "object",
422+
properties: {
423+
"animal": {
424+
"type": "array",
425+
"items": {
426+
"type": "string"
427+
},
428+
"example": [
429+
"1",
430+
"2"
431+
]
432+
}
433+
},
434+
xml: {
435+
name: "animals"
436+
}
437+
}
438+
439+
expect(sut(definition)).toEqual(expected)
440+
})
441+
442+
it("returns array with example values with wrapped=true", function () {
443+
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<animals>\n\t<animal>1</animal>\n\t<animal>2</animal>\n</animals>"
444+
var definition = {
445+
type: "array",
446+
items: {
447+
type: "string",
448+
xml: {
449+
name: "animal"
450+
}
451+
},
452+
"example": [ "1", "2" ],
453+
xml: {
454+
wrapped: true,
455+
name: "animals"
456+
}
457+
}
458+
459+
expect(sut(definition)).toEqual(expected)
416460
})
417461

462+
})
463+
418464
describe("object", function () {
419465
it("returns object with 2 properties", function () {
420466
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<aliens>\n\t<alien>string</alien>\n\t<dog>0</dog>\n</aliens>"

0 commit comments

Comments
 (0)