This library extends the swagger functionality, adding support for Faker.js attributes in the swagger spec file, by default it is the swagger.yaml file. Also adds support for generating fake values dynamically on each request.
Current fake data provider: Faker.js
Valid Custom Keys supported by swagger editor
firstName:
type: "string"
x-faker: "jf.name.firstName()"
Requires initial configuration in index.js to be able to intercept the responce before it is send to the receiver.
app.use((req, res, next) => justFake.intercept(req)
(middleware.swaggerRouter(options)(req, res, next)));
-
Query Provider
Added support for query params in generated data.
URL -> /authentication/login?username=John&password=Doe x-faker: "[{username}, {password}]" -> [ 'John', 'Doe' ]
Allows to easily extend the current functionality by registering a new provider. The providers are called when the statement is being processed.
justFake.register((statement, req) => {
// Do your magic!
})