2

I am trying to use what looks like a very promising mocking tool for openapi v3. It is called imposter.

However I have run into a problem. I have created an issue on gh for it, and I have even generated a pull request for what I believe may be a fix (but I am not a java guy, and cannot get the grade boilerplate stuff to run, not is there any documentation on how to do this).

My issue is (apart from the unanswered gh issue) is that I cannot get relative refs to work using this tool.

Basically after frantically trying things out I get to a point where there are no errors (so it silently fails) but also fails to load my relative ref docs.

This is extremely limiting for me, as I want to develop a complex api which would need to make use of this functionality to avoid ending up with monolithic spec documents.

I have tried a few other tools but they all seem to have relative refs as their achilles heel.

Has anyone managed to solve this, which should be a basic ask in 2022 for something that is now on version 3 of the specification??

  • You can try [bundling the files](https://stackoverflow.com/q/54586137/113116) into a single file, then feeding the resulting file to imposter. – Helen May 28 '22 at 17:04
  • Currently trying this. This does move the problem rather than solve it as all the bundlers are equally bad. :-/ – Charlie Benger-Stevenson May 29 '22 at 11:08

1 Answers1

0

When running the Imposter Docker container, place your files at the path /opt/imposter/config

This is the location that the mock engine looks for configuration files (i.e. those with the -config.yaml suffix).

In your specific case, it seems that if you amend your Dockerfile to this (in its entirety):

FROM outofcoffee/imposter
COPY ./config/* /opt/imposter/config/

...and run your docker build command (or Docker Compose command) from the directory containing your Dockerfile, then Imposter will be able to load your configuration file.

This assumes the folder structure mentioned in the GitHub issue you referenced:

projectroot/
    Dockerfile
    config/
      my-config.yaml
      api.yaml
      infrastructure/
        definition.yaml

For example:

$ docker build -t imposter-example .

Sending build context to Docker daemon   5.12kB
Step 1/2 : FROM outofcoffee/imposter
 ---> 36d19405d09b
Step 2/2 : COPY ./config/* /opt/imposter/config/
 ---> 1f2667a1d5e5
Successfully built 1f2667a1d5e5
Successfully tagged imposter-example:latest

$ docker run -it --rm -p 8080:8080 imposter-example

12:37:09 INFO  i.g.i.Imposter - Starting mock engine 2.13.0
...
12:37:11 INFO  i.g.i.Imposter - Mock engine up and running on http://localhost:8080
outofcoffee
  • 629
  • 6
  • 8