Hi!
Working in localhost env, we want to set 'sampleUrl' as the localhost host, to test more easily. While we still need to maintain it frequently, so it's not a good idea to put it in .gitignore.
How about providing an option to set the path for apidoc.json?
Thanks!
I also stumbled the same problem generating docs for different environments.
I see there can be several solutions:
apidoc.js config, so all the variables could be generated in run-timeAlso, according to documentation, there is a config switch, which might work as well, but you'll end up copy-pasting pretty much the whole file
-c, --config Path to directory containing config file (apidoc.json) [./]
Why do I need to create directory for each apidoc.json? Why do I can't specify path to file?
Something like apidoc -c ./apidoc-test.json would be much better.
I agree that the -c flag should be for a config file, not a directory. For backward compatibility, the code would need to determine if the path is a directory or a file, if a file, use that directly, if a directory, look for the config file inside.
can it use the dotenv lib? We are placing our generated docs into a docker image that can be pushed out to different environments. having dotenv, we can pass in the url/sampleUrl when we startup the docker container.
@javajoe1 Dotenv sounds like a good idea. Please feel free to submit a PR for this feature :)
I found a solution to specify sampleUrl or any other apidocjson setting as per our application environment.
Suppose we have four env - local,dev,stage,prod
These env will have their specific sampleUrl
Just create apidoc-
apidoc-local.json
apidoc-dev.json
apidoc-stage.json
apidoc-prod.json
In each we specify their respective setting
Now just write a bash script like apidoc.sh contain following code -
cp apidoc-$1.json apidoc.json
apidoc -f "./src/routes/.*\\.js$" -i ./ -o public/apidoc/
rm apidoc.json
now everytime you want to create apidoc with any environment ,just execute it with following command -
sh ./apidoc.sh <env>
Example -
sh ./apidoc.sh dev
sh ./apidoc.sh local
by this,it will create apidoc with dynamic environment.
Most helpful comment
Why do I need to create directory for each
apidoc.json? Why do I can't specify path to file?Something like
apidoc -c ./apidoc-test.jsonwould be much better.