Tool for checking consistency between swagger file and routes in phoenix application. Use only with phoenix framework.
If available in Hex, the package can be installed
by adding swapi
to your list of dependencies in mix.exs
:
def deps do
[{:swapi, "~> 0.1.0", only: :dev}]
end
Otherwise please add it with git:
directive:
def deps do
{:swapi, git: "git@github.com:FactomProject/swapi.git", only: :dev},
end
mix swapi swagger.yaml
where swagger.yaml
is a swagger specification file.
Sometimes paths in swagger file and routes are consistent but because
documentation, and developer convenience could differ parameters have different
names, like: /users/:user_id
vs. /users/:id
. You may use --uniform
option
which will change given path parameters to :param1
, :param2
etc.
mix swapi swagger.yaml --uniform
This way you can still check if documentation and routes are consistent but preserve naming (which is hard).
Right now swapi
omits PATCH
methods, as phoenix generates those and PUT
methods with resource
directive for updates, making it redundant.