Przeglądaj źródła

Merge branch 'master' of github.com:swagger-api/swagger-ui into ft/linting-and-testing

bubble
Kyle Shockey 7 lat temu
rodzic
commit
8dd23053b2
5 zmienionych plików z 72 dodań i 8 usunięć
  1. +2
    -0
      README.md
  2. +1
    -1
      dist/swagger-ui-bundle.js
  3. +1
    -1
      dist/swagger-ui-standalone-preset.js
  4. +21
    -5
      src/core/plugins/samples/fn.js
  5. +47
    -1
      test/core/plugins/samples/fn.js

+ 2
- 0
README.md Wyświetl plik

@@ -54,6 +54,8 @@ To help with the migration, here are the currently known issues with 3.X. This l
- The JSON Form Editor is not implemented.
- Shebang URL support for operations is missing.
- Support for `collectionFormat` is partial.
- l10n (translations) is not implemented.
- Relative path support for external files is not implemented.


## CORS Support


+ 1
- 1
dist/swagger-ui-bundle.js Wyświetl plik

@@ -24,7 +24,7 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
"use strict";function n(e){return e instanceof t||e instanceof Date||e instanceof RegExp}function r(e){if(e instanceof t){var n=new t(e.length);return e.copy(n),n}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e);throw new Error("Unexpected situation")}function o(e){var t=[];return e.forEach(function(e,a){"object"==typeof e&&null!==e?Array.isArray(e)?t[a]=o(e):n(e)?t[a]=r(e):t[a]=i({},e):t[a]=e}),t}var i=e.exports=function(){if(arguments.length<1||"object"!=typeof arguments[0])return!1;if(arguments.length<2)return arguments[0];var e,t,a=arguments[0],s=Array.prototype.slice.call(arguments,1);return s.forEach(function(s){"object"!=typeof s||Array.isArray(s)||Object.keys(s).forEach(function(u){return t=a[u],e=s[u],e===a?void 0:"object"!=typeof e||null===e?void(a[u]=e):Array.isArray(e)?void(a[u]=o(e)):n(e)?void(a[u]=r(e)):"object"!=typeof t||null===t||Array.isArray(t)?void(a[u]=i({},e)):void(a[u]=i(t,e))})}),a}}).call(t,n(3).Buffer)},function(e,t,n){(function(e){/*!
"use strict";function n(e){return e instanceof t||e instanceof Date||e instanceof RegExp}function r(e){if(e instanceof t){var n=new t(e.length);return e.copy(n),n}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e);throw new Error("Unexpected situation")}function i(e){var t=[];return e.forEach(function(e,a){"object"==typeof e&&null!==e?Array.isArray(e)?t[a]=i(e):n(e)?t[a]=r(e):t[a]=o({},e):t[a]=e}),t}var o=e.exports=function(){if(arguments.length<1||"object"!=typeof arguments[0])return!1;if(arguments.length<2)return arguments[0];var e,t,a=arguments[0],s=Array.prototype.slice.call(arguments,1);return s.forEach(function(s){"object"!=typeof s||Array.isArray(s)||Object.keys(s).forEach(function(u){return t=a[u],e=s[u],e===a?void 0:"object"!=typeof e||null===e?void(a[u]=e):Array.isArray(e)?void(a[u]=i(e)):n(e)?void(a[u]=r(e)):"object"!=typeof t||null===t||Array.isArray(t)?void(a[u]=o({},e)):void(a[u]=o(t,e))})}),a}}).call(t,n(3).Buffer)},function(e,t,n){(function(e){/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>


+ 1
- 1
dist/swagger-ui-standalone-preset.js
Plik diff jest za duży
Wyświetl plik


+ 21
- 5
src/core/plugins/samples/fn.js Wyświetl plik

@@ -127,8 +127,12 @@ export const sampleXmlFromSchema = (schema, config={}) => {

if (xml.wrapped) {
res[displayName] = []
if (Array.isArray(defaultValue)) {

if (Array.isArray(example)) {
example.forEach((v)=>{
items.example = v
res[displayName].push(sampleXmlFromSchema(items, config))
})
} else if (Array.isArray(defaultValue)) {
defaultValue.forEach((v)=>{
items.default = v
res[displayName].push(sampleXmlFromSchema(items, config))
@@ -145,14 +149,20 @@ export const sampleXmlFromSchema = (schema, config={}) => {

let _res = []

if (Array.isArray(defaultValue)) {
if (Array.isArray(example)) {
example.forEach((v)=>{
items.example = v
_res.push(sampleXmlFromSchema(items, config))
})
return _res
} else if (Array.isArray(defaultValue)) {
defaultValue.forEach((v)=>{
items.default = v
_res.push(sampleXmlFromSchema(items, config))
})
return _res

}

return sampleXmlFromSchema(items, config)
}
}
@@ -176,7 +186,13 @@ export const sampleXmlFromSchema = (schema, config={}) => {
} else {
props[propName].xml.name = props[propName].xml.name || propName
props[propName].example = props[propName].example !== undefined ? props[propName].example : example[propName]
res[displayName].push(sampleXmlFromSchema(props[propName]))
let t = sampleXmlFromSchema(props[propName])
if (Array.isArray(t)) {
res[displayName] = res[displayName].concat(t)
} else {
res[displayName].push(t)
}

}
}
}


+ 47
- 1
test/core/plugins/samples/fn.js Wyświetl plik

@@ -396,7 +396,7 @@ describe("createXMLExample", function () {
})

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

expect(sut(definition)).toEqual(expected)
})

it("returns array with example values with ", function () {
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<animals>\n\t<animal>1</animal>\n\t<animal>2</animal>\n</animals>"
var definition = {
type: "object",
properties: {
"animal": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"1",
"2"
]
}
},
xml: {
name: "animals"
}
}

expect(sut(definition)).toEqual(expected)
})

it("returns array with example values with wrapped=true", function () {
var expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<animals>\n\t<animal>1</animal>\n\t<animal>2</animal>\n</animals>"
var definition = {
type: "array",
items: {
type: "string",
xml: {
name: "animal"
}
},
"example": [ "1", "2" ],
xml: {
wrapped: true,
name: "animals"
}
}

expect(sut(definition)).toEqual(expected)
})

})

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


Ładowanie…
Anuluj
Zapisz