How to use mock-json-schema - 1 common examples

To help you get started, we’ve selected a few mock-json-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anttiviljami / openapi-backend / src / backend.ts View on Github external
}
    }

    // if operation has an example, return its value
    if (mediaResponse.example && mediaResponse.example.value) {
      return mediaResponse.example.value;
    }

    // pick the first example from examples
    if (examples) {
      const exampleObject = examples[_.first(_.keys(examples))] as OpenAPIV3.ExampleObject;
      return exampleObject.value;
    }

    if (schema) {
      return mock(schema as OpenAPIV3.SchemaObject);
    }
    return defaultMock;
  }

mock-json-schema

Simple utility to mock example objects based on JSON schema definitions

MIT
Latest version published 4 years ago

Package Health Score

47 / 100
Full package analysis

Popular mock-json-schema functions