How to use the @ts-common/iterator.filter function in @ts-common/iterator

To help you get started, we’ve selected a few @ts-common/iterator 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 Azure / oav / lib / validators / modelValidator.ts View on Github external
}

      // ensure content-type header is present
      if (!(exampleResponseHeaders["content-type"] || exampleResponseHeaders["Content-Type"])) {
        exampleResponseHeaders["content-type"] = utils.getJsonContentType(operation.produces)
      }
      const exampleResponse = new ResponseWrapper(
        exampleResponseStatusCode,
        exampleResponseBody,
        exampleResponseHeaders
      )
      const validationResult = this.validateResponse(operation, exampleResponse)
      result[exampleResponseStatusCode] = validationResult
    }
    const responseWithoutXmsExamples = toArray(
      filter(sm.keys(responsesInSwagger), statusCode => statusCode !== "default")
    )

    if (responseWithoutXmsExamples && responseWithoutXmsExamples.length) {
      const msg =
        `Following response status codes "${responseWithoutXmsExamples.toString()}" for ` +
        `operation "${operation.operationId}" were present in the swagger spec, ` +
        `however they were not present in x-ms-examples. Please provide them.`
      const e = this.constructErrorObject({
        code: C.ErrorCodes.ResponseStatusCodeNotInExample,
        message: msg,
        source: operation.definition
      })
      setPositionAndUrl(e, getTitle(operation.definition))
      log.error(e as any)
      responseWithoutXmsExamples.forEach(statusCode => (result[statusCode] = { errors: [e] }))
    }