I downloaded the latest stable version of swagger codegen (3.0.50 currently) and I intend to use it to generate documentation in html format for a rest API I previously developed. I managed to generate a first version of the documentation, but I saw that there are various elements that I would like to change:
- Leave only the examples for Curl and Python in the nav-tab-examples (I'm not interested in the others);
- In the Python example, I want to replace the code example with one written by me, which does not use the swagger_client library but the requests library to make calls to the endpoints;
- I would like to generate two distinct templates, one for the get calls and one for the post ones, and be sure that swagger codegen inserts them in the correct places in the documentation (while now the example is the same for everyone, apart from some small differences) .
For point (2) I saw that I could directly modify the .mustache template used by swagger codegen, which should be in modules/swagger-codegen/src/main/resources/htmlDocs2/sample_python.mustache
, but:
- under
modules/swagger-codegen/src/main/resources
I don't find any subfolders; - I still tried to write my own .mustache template (along the lines of this one) and passed the folder into the java command (
java -jar swagger-codegen-3.0.50\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i openapi_new.json -l html2 -t swagger-codegen-3.0.50\modules\swagger-codegen\src\main\resources\htmlDocs2 -c config.json
), but swagger codegen didn't consider it.
Can someone help me? I tried to rely on the official documentation, but I can't quite understand how to proceed.
I've resolved my problems, writing three different templates (one for curl and two for python) and modifying the index.mustache template in the subfolder htmlDocs2. In particular:
P.s.: I'm not an expert with html and javascript coding, so there's probably a better way to do what I need, but in my case the script works.