Closed cianfoley-nearform closed 6 years ago
In the https://github.com/nearform/trail repository I followed a different approach. The Swagger JSON file is generated on the fly, so we don't have to remember about scripts and similar.
Since the parsing is only done once on startup, there's no performance overhead (rather than keeping the small JSON file in memory).
Hope this helps!
I put swagger-ui-dist 3.14.1 (latest), into a subfolder of docs/swagger so that the distribution remains intact, if upgrading in future, this folder can be replaced wholesale...
Specific files we need such as the css, swagger-json.js and index.htm are in the root of docs/swagger
For future updates to docs this will keep the process of upgrading simple and stable.
swagger-gen npm command simply creates a swagger-json.js file, which index loads as per previous swagger-gen package.
The only item required to updated when updating swagger docs is that we update the swagger-json.js file.
For some reason the script section that swagger-gen replaces stopped working recently so it is probably a safer approach to just update the json and js files when performing an update. This should probably form part of every commit.
We can probably remove swagger-gen at this point as currently it is not working.
I updated the getSwagger.json to take an optional command like parameter js to generate json and assign to variable, without it, it works as previously and just outputs the json stringified.