CrudApiPlugin: Add getRandom action type
- Lenguaje dominante
- C#
- Estrellas
- 832
- Forks
- 89
- Merge medio
- 12 h 1 min
- PR fusionados (30 d)
- 23
Descripción
## 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
```json
{
"action": "getRandom",
"url": "/random"
}
```
### Expected behavior
`GET /baseUrl/random` returns a single random item from the data file, e.g.:
```json
{
"id": 42,
"setup": "Why did the MVP cross the road?",
"punchline": "To screenshot the chicken for LinkedIn."
}
```
## Use case
Simulating the [MVP Jokes API](https://github.com/laskewitz/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.
Guía de contribución
Línea de trabajo
Comienza localizando el manejo del tipo de acción de CrudApiPlugin y la ruta getAll existente. Añade el comportamiento de configuración propuesto para getRandom y, después, verifica que GET /baseUrl/random devuelva un elemento del archivo de datos en lugar de la colección completa.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp
- Área
- api, backend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 68/100