Importing Swagger UI #2877
Importing Swagger UI
#2877
-
I have a custom component called <script>
import SwaggerUI from 'swagger-ui-dist/swagger-ui-bundle.js';
import 'swagger-ui-dist/swagger-ui.css';
export default {
name: 'SwaggerUI',
props: {
url: {
type: String,
required: true
},
isDark: {
type: Boolean,
default: false
}
},
data() {
return {
dark: "dark",
light: "light"
}
},
watch: {
isDark: function (val) {}
},
mounted() {
SwaggerUI({
dom_id: '#swagger-ui',
url: this.url,
presets: [
SwaggerUI.presets.apis,
SwaggerUI.SwaggerUIStandalonePreset
],
})
}
}
</script> It was working fine until
I am able to start the dev server though. I tried adding the following vite configs: export default defineConfig({
// ...
vite: {
build: {
commonjsOptions: { transformMixedEsModules: true, include: [] },
},
optimizeDeps: {
disabled: false,
},
}
}) But that didn't fix too. Any help is appreciated. |
Beta Was this translation helpful? Give feedback.
Answered by
brc-dd
Aug 30, 2023
Replies: 1 comment 4 replies
-
Have you tried adding 'swagger-ui-dist/swagger-ui-bundle.js' to |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some reports on Swagger's repo suggest using Node 20 works 👀 Can you try that once as well? I'll take a look otherwise.
Seems like it tries to use browser only APIs in it's classes. Dynamic importing those packages inside onMounted should also work.