Skip to content

Commit

Permalink
use parameters examples
Browse files Browse the repository at this point in the history
  • Loading branch information
albanm committed May 31, 2017
1 parent 2a75a17 commit 73ca562
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/OpenApi.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/petstore.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@
"required": true,
"schema": {
"type": "string"
}
},
"example": "rex"
}],
"responses": {
"405": {
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = {
secure: false
}]
},
devtool: '#eval-source-map'
devtool: '#eval'
}

if (process.env.NODE_ENV === 'production') {
Expand Down

0 comments on commit 73ca562

Please sign in to comment.