Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for External JSON File References in Mock Configurations #121

Open
2 tasks done
rhenness opened this issue Oct 4, 2023 · 1 comment
Open
2 tasks done

Comments

@rhenness
Copy link

rhenness commented Oct 4, 2023

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure a similar issue has not already been created

Description

We often have scenarios where our mocked HTTP responses are quite extensive, making our Mockaco configuration JSON files long and harder to manage. To enhance readability and maintainability, we'd like to propose a feature that allows external JSON file references within the mock files.

Proposed solution

It would be beneficial to have a syntax or mechanism in the mock configurations that can specify an external JSON file to be read and inlined during the mock's runtime. For example:

{
  "request": {
    "method": "GET",
    "route": "largeResponseEndpoint"
  },
  "response": {
    "status": "OK",
    "body": "<#= ReadExternalJson("Mocks/some-data.json") #>"
  }
}

Alternatives

Enhance the Global object to allow users to define and set values that persist throughout the lifecycle of the Mockaco service. This would enable setting large common response structures or data once and then reference them in multiple mock endpoints.

For example:

<#
Global["some-data"] = { name: 'Bob' }
#>

Additional context

No response

@rhenness rhenness added the enhancement New feature or request label Oct 4, 2023
@natenho
Copy link
Owner

natenho commented Oct 9, 2023

Hi @ryan-henness-trimble, have you considered the file attribute? Please have a look at

Let me know if that works for you.

@natenho natenho removed the enhancement New feature or request label Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants