0

I would like to use this docker container apiaryio/dredd instead of the npm package dredd. I am not familiar with running and debugging npm based docker images. How can I run the basic usage example of the npm package "Quick Start" section

$ dredd init
$ dredd

if I have a Swagger file instead of the api-description.apib in $PWD/api/api.yaml or $PWD/api/api.json?

thinwybk
  • 4,193
  • 2
  • 40
  • 76

1 Answers1

1

TL;DR

Run dredd image as a command line. Dredd Image at Docker Hub

docker run -it -v $PWD:/api -w /api apiaryio/dredd init

[Optional] Turn it into a script:

#!/bin/bash
echo '***'
echo 'Root dir is /api'
export MYIP=`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'`
echo 'Host ip is: ' $MYIP
echo 'Configure URL of tested API endpoint: http://api-srv::<enpoint-port>. Set api-srv to point to your server.'
echo 'This script will set api-srv to docker host machine - ' $MYIP
echo '***'

docker run -it --add-host "api-srv:$MYIP" -v $PWD:/api -w /api apiaryio/dredd dredd $1

[Optional] And put this script in a folder that is in your PATH variable and create an alias for short it

alias dredd='bash ./scripts/dredd.sh'

Code at Github gist.