Skip to content

Commit

Permalink
feat: ✨ display OAS3 version on badges
Browse files Browse the repository at this point in the history
  • Loading branch information
marcodarko committed Jul 3, 2024
1 parent 7c14b87 commit b3abd42
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion web-app/src/components/RegistryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
></UptimeStatus>
</span>
<div>
<span v-if="api?.openapi" class="versionBadge green"> OAS3 </span>
<span v-if="api?.openapi" class="versionBadge green"> OAS3 {{ api?.openapi.includes('.') ? " " + api?.openapi.split('.', 2).join('.') : " " + api?.openapi }}</span>
<span v-else-if="api?.swagger" class="versionBadge blue"> Swagger2 </span>
<span
v-if="api?.info?.['x-trapi']?.version"
Expand Down
7 changes: 6 additions & 1 deletion web-app/src/views/UI.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export default {
name: '',
api: Object,
//ensure nav has mounted for teleport to work
ready: false
ready: false,
openapi: ''
});
const route = useRoute();
Expand All @@ -100,6 +101,7 @@ export default {
// useMeta(computedMeta)
let loadSwaggerUI = (dataurl) => {
const HideEmptyTagsPlugin = () => {
return {
Expand Down Expand Up @@ -141,6 +143,8 @@ export default {
'<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>'
);
}
document.querySelector('.swagger-ui .info .title small.version-stamp pre.version')
.insertAdjacentHTML('beforeend', data?.openapi.includes('.') ? " " + data?.openapi.split('.', 2).join('.') : " " + data?.openapi)
}
}
});
Expand All @@ -152,6 +156,7 @@ export default {
.get(url)
.then((res) => {
data.api = res.data;
data.openapi = res.data?.openapi
})
.catch((err) => {
throw err;
Expand Down

0 comments on commit b3abd42

Please sign in to comment.