I am using swagger core to generate my swagger specification files. I am also using swagger ui dist folder to access swagger ui. To view my swagger document with index.html, i have generated swagger.json using rest client, then copy the spec into a file named response.json then put that file into swagger ui dist folder. From there i can change the url in index.html into the path to the spec file. Each time i add swagger annotations on the resource classes, i build the project and a new swagger.json gets generated and i have change the contents of the response.json into my new swagger.json to view the new changes made.
Is there a way that after building my project, it will first hit the endpoint to generate swagger.json and save it as response.json in our swagger-ui folder?
Originally posted by RonRatovsky on August 12, 2019
Generally speaking, swagger-core generates the API definition at runtime (just like another API endpoint). It’s a bit unclear from your description how your application works. so:
If your UI is intended to run alongside the API, you can simply point the UI to the generated definition at runtime. That way it’s always up to date and there’s no issue.
I would like to point the UI to the generated definition at runtime but i get a “Failed to Load spec”. This may be because to access the definition, there must be some authentication and custom header added. I am using a url like this on index.html
Also the try it out buttons on the swagger ui do not function when i use the path url to the locally saved swagger spec. I think it may be due to the authentication and header to be added on every request inorder to access to the server. How can i resolve this please?