osprey-mock-service icon indicating copy to clipboard operation
osprey-mock-service copied to clipboard

Support for mocking some endpoints but not others

Open danday74 opened this issue 6 years ago • 1 comments

Say I have two resources:

/a AND /b

I want to use osprey-mock-service as a validation proxy that can:

  • mock requests to /a
  • reverse proxy requests to /b to another server
  • reverse proxy requests to /c (unknown RAML resource) to another server

The use case is that there is an existing API. Existing resources we don't care about and don't want to produce a RAML definition for them. New resources, we want to either mock or reverse proxy depending on whether the resource is ready. Mock mode should give us full control to do all the above. Live mode should always reverse proxy ALL requests to another server (whilst still working as a validation proxy).

Is this possible?

We cannot use the online tool for this since company policy prevents use from sending info about our API to a third party.

Thanks in advance.

At the moment I can probably utilise osprey-mock-service to mock ALL requests or NONE but not SOME

maybe this is already possible. If so, a code example would be appreciated.

danday74 avatar Apr 23 '18 13:04 danday74

Have you looked into using RAML extensions?

One way to go about what you're trying to do would be to define all your non-mockable/already-implemented endpoints inside a RAML extension. Then inside the RAML file that that RAML extension extends, define all the mocked endpoints. With that approach, you can have osprey-mock-service point to the main RAML file for mocking; and something like Osprey point to the RAML extension for handling reverse-proxying.

jstoiko avatar Apr 23 '18 17:04 jstoiko