Apidoc: Is there a way to set different apidoc.json

Created on 12 Apr 2018  路  6Comments  路  Source: apidoc/apidoc

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!

enhancement fixed on dev

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.json would be much better.

All 6 comments

I also stumbled the same problem generating docs for different environments.
I see there can be several solutions:

  • Generate apidoc.json on the fly for each build (not that good)
  • Have an option to use apidoc.js config, so all the variables could be generated in run-time

Also, 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-.json with respect to these env like-
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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandonhamilton picture brandonhamilton  路  4Comments

a-tonchev picture a-tonchev  路  4Comments

YannDoW picture YannDoW  路  4Comments

imfuxiao picture imfuxiao  路  6Comments

Abdelrhman-Hosny picture Abdelrhman-Hosny  路  3Comments