Skip to content

Commit

Permalink
feat: show entry description + fix reactivity of params + wrap respon…
Browse files Browse the repository at this point in the history
…se body
  • Loading branch information
albanm committed Mar 28, 2018
1 parent 47198e0 commit f3fb5be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/OpenApi.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
</md-layout>

<md-layout md-column md-flex-offset="5" md-flex="true" v-if="selectedEntry">
<h2 class="md-title">{{selectedEntry.summary}}</h2>
<h2 class="md-title">{{selectedEntry.title || selectedEntry.summary}}</h2>
<p class="entry-description" v-html="marked(selectedEntry.description)"></p>
<h3 class="md-subheading">{{selectedEntry.method.toUpperCase()}} {{api.servers[0].url + selectedEntry.path}}</h3>
<md-tabs md-right class="md-transparent" style="margin-top:-54px">
<md-tab md-label="Documentation">
Expand Down Expand Up @@ -122,6 +123,10 @@
.schema-dialog .md-dialog {
min-width: 800px;
}
.openapi .entry-description {
margin: 0;
}
</style>

<script>
Expand Down Expand Up @@ -152,7 +157,8 @@ export default {
currentExamples: [],
currentRequest: {
contentType: '',
body: ''
body: '',
params: {}
},
currentResponse: null
}),
Expand Down Expand Up @@ -186,21 +192,22 @@ export default {
methods: {
marked,
reset(entry) {
this.currentRequest.params = {};
const newParams = {};
(entry.parameters || []).forEach(p => {
this.currentRequest.params[p.name] = (p.in === 'query' && this.queryParams && this.queryParams[p.name]) || (p.in === 'header' && this.headers && this.headers[p.name]) || null
if (!this.currentRequest.params[p.name]) {
if (!newParams[p.name]) {
if (p.schema && p.schema.enum) {
this.currentRequest.params[p.name] = p.schema.enum[0]
newParams[p.name] = p.schema.enum[0]
}
if (p.schema && p.schema.type === 'array') {
this.currentRequest.params[p.name] = []
newParams[p.name] = []
}
if (p.example) {
this.currentRequest.params[p.name] = p.example
newParams[p.name] = p.example
}
}
})
this.currentRequest.params = newParams
if (entry.requestBody) {
this.currentRequest.contentType = entry.requestBody.selectedType
const example = entry.requestBody.content[this.currentRequest.contentType].example
Expand Down
3 changes: 3 additions & 0 deletions src/ResponseDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ export default {
</script>

<style lang="css">
.response-display pre {
white-space: pre-wrap;
}
</style>

0 comments on commit f3fb5be

Please sign in to comment.