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

Feature request: Generating mocks responses #91

Open
rodriguezc opened this issue May 2, 2019 · 1 comment
Open

Feature request: Generating mocks responses #91

rodriguezc opened this issue May 2, 2019 · 1 comment

Comments

@rodriguezc
Copy link

rodriguezc commented May 2, 2019

I implemented a controller that send mocks response using json-schema-faker v0.4.7.
myController.js

const jsf = require('json-schema-faker');
jsf.option({ optionalsProbabilty: 0.5 });
const jsonSchema = require("exegesis/lib/utils/jsonSchema");
exports.getPartenaireById = function getPartenaireById(context) {
    const path = `${context.api.operationPtr}/responses/200/content/application~1json/schema`;
    let schema = jsonSchema.extractSchema(context.api.openApiDoc, path);
    const mock = jsf(schema);

    return mock;
}

Perhaps you have a good solution to make it generic and integrate it in the core or in a plugin?

Thanks

@jwalton
Copy link
Contributor

jwalton commented May 3, 2019

Oh, very slick! It would be very cool to have this as a plugin.

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