diff --git a/src/OpenApi.vue b/src/OpenApi.vue index 0fd98ff..3e135d7 100644 --- a/src/OpenApi.vue +++ b/src/OpenApi.vue @@ -227,6 +227,20 @@ function reset(request, entry) { request.params = Object.assign({}, ...(entry.parameters || []).map(p => ({ [p.name]: p.schema.enum ? p.schema.enum[0] : (p.schema.type === 'array' ? [] : null) }))) + + request.params = {}; + (entry.parameters || []).forEach(p => { + request.params[p.name] = null + if (p.schema && p.schema.enum) { + request.params[p.name] = p.schema.enum[0] + } + if (p.schema && p.schema.type === 'array') { + request.params[p.name] = [] + } + if (p.example) { + request.params[p.name] = p.example + } + }) if (entry.requestBody) { request.contentType = entry.requestBody.selectedType const example = entry.requestBody.content[request.contentType].example @@ -325,6 +339,7 @@ function getTag(api) { } // Some preprocessing with responses + entry.responses = entry.responses || {} Object.values(entry.responses).forEach(response => { if (response.content) { // preselecting responses mime-type diff --git a/test/petstore.json b/test/petstore.json index be93fe2..3dbfb58 100644 --- a/test/petstore.json +++ b/test/petstore.json @@ -267,7 +267,8 @@ "required": true, "schema": { "type": "string" - } + }, + "example": "rex" }], "responses": { "405": { diff --git a/webpack.config.js b/webpack.config.js index 54c2e07..6c5c49d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -40,7 +40,7 @@ module.exports = { secure: false }] }, - devtool: '#eval-source-map' + devtool: '#eval' } if (process.env.NODE_ENV === 'production') {