I\'m trying to open my self generated swagger specification file my.json
with swagger-ui on my local computer.
So I downloaded the latest tag v2.1.8-M1
LINUX
I always had issues while trying paths and the spec parameter.
Therefore I went for the online solution that will update automatically the JSON on Swagger without having to reimport.
If you use npm to start your swagger editor you should add a symbolic link of your json file.
cd /path/to/your/swaggerui
where index.html
is.
ln -s /path/to/your/generated/swagger.json
You may encounter cache problems. The quick way to solve this was to add a token at the end of my url...
window.onload = function() {
var noCache = Math.floor((Math.random() * 1000000) + 1);
// Build a system
const editor = SwaggerEditorBundle({
url: "http://localhost:3001/swagger.json?"+noCache,
dom_id: '#swagger-editor',
layout: 'StandaloneLayout',
presets: [
SwaggerEditorStandalonePreset
]
})
window.editor = editor
}