CrudApiPlugin: Add getRandom action type
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start by locating CrudApiPlugin's action-type handling and the existing getAll path. Add the proposed getRandom configuration behavior, then verify that GET /baseUrl/random returns one item from the data file rather than the full collection.
Written by the indexing model from the issue text.
Description
Description
When simulating APIs with CrudApiPlugin, there's currently no way to return a random item from the data store. This is a common API pattern (e.g. GET /jokes/random) that can't be replicated with the existing action types.
Proposed solution
Add a getRandom action type that picks a random item from the data file and returns it as a single object.
Example configuration
{
"action": "getRandom",
"url": "/random"
}
Expected behavior
GET /baseUrl/random returns a single random item from the data file, e.g.:
{
"id": 42,
"setup": "Why did the MVP cross the road?",
"punchline": "To screenshot the chicken for LinkedIn."
}
Use case
Simulating the MVP Jokes API which has a GET /jokes/random endpoint. Currently, there's no way to mock this with CrudApiPlugin — the closest workaround is getAll which returns all items instead of a random one.
- Dominant language
- C#
- Stars
- 832
- Forks
- 89
- Avg merge
- 13h 17m
- Merged PRs (30d)
- 42
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/dev-proxy
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
work in progress
Difficulty 4/5 3-5 days Newbie friendliness 55/100
dotnet/dev-proxy#1800 · 7 comments · 1 reaction · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
All issues in dotnet/dev-proxy
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nightscout/nocturne#1379 ·
-
priority-0
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
StackExchange/StackExchange.Redis#3249 ·
-
[Feat] 조합 영역 구분선 개선 Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100