@aida/injector-faked-routes
v0.0.7
Published
Aida injector to create faked routes
Downloads
15
Readme
Injector - Faked Routes
Introduction
The Faked Routes injector generates a flat object with all defined endpoints, similar in structure to the .endpoints.js file, except that data models are replaced with mocked data.
Dependencies
The Faked Routes injector depends on:
Use Cases
The main use case for this injector is to mock endpoints with fake data. For now, this injector is supposed to be used for request-response endpoints. There is no support for streaming, websockets, or GraphQL yet. Moreover, the only supported response content type is "application/json". The results from this injector can be used by the @aida/consumer-faked-http consumer to mock APIs without making network calls to a backend.
Example
// This is an example of how the data generated by this injector looks like. For more details on how to use this with the faked-http consumer, check the consumer documentation.
const fakedRoutes = {
"/users": {
"put": {
"operationId": "updateUser",
"request": {
"body": {
"id": "27bd418b-05e0-4e40-9fb2-54a9ff7de038",
"email": "[email protected]",
"phoneNumber": "914.750.8191 x2376",
"firstName": "Bobby"
}
},
"response": {
"200": {
"application/json": {
"id": "27bd418b-05e0-4e40-9fb2-54a9ff7de038",
"email": "[email protected]",
"phoneNumber": "914.750.8191 x2376",
"firstName": "Bobby"
}
},
"400": {
"application/json": {
"description": "Quod officiis voluptatem dicta provident est. Aliquid sint aperiam."
}
}
}
}
},
"/users/{id}": {
"get": {
"operationId": "getUser",
"request": {
"path": {
"id": "27bd418b-05e0-4e40-9fb2-54a9ff7de038"
}
},
"response": {
"200": {
"application/json": {
"id": "27bd418b-05e0-4e40-9fb2-54a9ff7de038",
"email": "[email protected]",
"phoneNumber": "914.750.8191 x2376",
"firstName": "Bobby"
}
}
}
}
}
}
API
options
seed
: An integer to serve as the seed for the random data generation. Defaults to12
.