Skip to content

Commit d9ce312

Browse files
authored
Merge pull request #258 from SmartAPI/badges
feat: ✨ display OAS3 version on badges
2 parents 7c14b87 + b3abd42 commit d9ce312

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

web-app/src/components/RegistryItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
></UptimeStatus>
1212
</span>
1313
<div>
14-
<span v-if="api?.openapi" class="versionBadge green"> OAS3 </span>
14+
<span v-if="api?.openapi" class="versionBadge green"> OAS3 {{ api?.openapi.includes('.') ? " " + api?.openapi.split('.', 2).join('.') : " " + api?.openapi }}</span>
1515
<span v-else-if="api?.swagger" class="versionBadge blue"> Swagger2 </span>
1616
<span
1717
v-if="api?.info?.['x-trapi']?.version"

web-app/src/views/UI.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ export default {
8686
name: '',
8787
api: Object,
8888
//ensure nav has mounted for teleport to work
89-
ready: false
89+
ready: false,
90+
openapi: ''
9091
});
9192
9293
const route = useRoute();
@@ -100,6 +101,7 @@ export default {
100101
101102
// useMeta(computedMeta)
102103
104+
103105
let loadSwaggerUI = (dataurl) => {
104106
const HideEmptyTagsPlugin = () => {
105107
return {
@@ -141,6 +143,8 @@ export default {
141143
'<div class="yellow lighten-4 red-text padding20"> <i class="material-icons">warning</i> Your connection is secure (HTTPS) and the selected server utilizes an insecure communication (HTTP). <br/>This will likely result in errors, please select a matching protocol server or change your connection. </div>'
142144
);
143145
}
146+
document.querySelector('.swagger-ui .info .title small.version-stamp pre.version')
147+
.insertAdjacentHTML('beforeend', data?.openapi.includes('.') ? " " + data?.openapi.split('.', 2).join('.') : " " + data?.openapi)
144148
}
145149
}
146150
});
@@ -152,6 +156,7 @@ export default {
152156
.get(url)
153157
.then((res) => {
154158
data.api = res.data;
159+
data.openapi = res.data?.openapi
155160
})
156161
.catch((err) => {
157162
throw err;

0 commit comments

Comments
 (0)