How to use the monocle-ts.Optional.fromNullableProp function in monocle-ts

To help you get started, we’ve selected a few monocle-ts 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 unmock / unmock-js / packages / unmock-core / src / generator-experimental.ts View on Github external
  .modify(oai => Optional.fromNullableProp()("paths")
    .composeIso(objectToArray())
    .composeTraversal(fromTraversable(array)())
    .composeLens(valueLens())
    .modify(pathItem => prunePathItem(req.method, pathItem)) (
        {
          ...oai,
          ...(oai.paths ? {
              paths: Object.entries(oai.paths)
                .reduce((i, [n, o]) =>
                  ({
                      ...i,
                      ...(
                          matches(
                            truncatePath(req.pathname, oai, req),
                            n,
                            o,
github unmock / unmock-js / packages / unmock-core / src / generator.ts View on Github external
const bodyFromResponse = (
  schema: OpenAPIObject,
  operation: Operation,
  code: keyof Responses,
) =>
  makeLensToResponseStartingFromOperation(schema, code)
    .composeOptional(Optional.fromNullableProp()("content"))
    .composeIso(objectToArray())
    .composeOptional(firstElementOptional())
    .composeLens(valueLens())
    .composeOptional(Optional.fromNullableProp()("schema"))
    .getOption(operation);