How to use the @ts-common/iterator.toArray 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
for (const [responseStatusCode, value] of sm.entries(responseValidation)) {
            this.constructResponseResultWrapper(
              operationId,
              responseStatusCode,
              value.errors,
              value.warnings,
              exampleType,
              scenario
            )
          }
        }
      }
    } else if (exampleType === C.exampleInSpec) {
      if (
        result.requestValidation &&
        toArray(sm.keys(result.requestValidation as sm.StringMap)).length
      ) {
        // requestValidation
        const validationResult = result.requestValidation.validationResult
        if (validationResult === undefined) {
          throw new Error("validationResult is undefined")
        }
        const requestValidationErrors = validationResult.errors
        const requestValidationWarnings = validationResult.warnings
        this.constructRequestResultWrapper(
          operationId,
          requestValidationErrors,
          requestValidationWarnings,
          exampleType
        )
      }
      if (result.responseValidation && !sm.isEmpty(result.responseValidation)) {
github Azure / oav / lib / validators / specResolver.ts View on Github external
private unifyXmsPaths(): void {
    // unify x-ms-paths into paths
    const xmsPaths = this.specInJson["x-ms-paths"]
    const paths = this.specInJson.paths as PathsObject
    if (xmsPaths && xmsPaths instanceof Object && toArray(sm.keys(xmsPaths)).length > 0) {
      for (const [property, v] of sm.entries(xmsPaths)) {
        paths[property] = v
      }
      this.specInJson.paths = utils.mergeObjects(xmsPaths, paths)
    }
  }
github Azure / azure-rest-api-specs / scripts / multiapi.ts View on Github external
const readMeMulti = cm.createNode(
          "document",
          cm.createNode(
            "heading",
            cm.createText("Multi-API support for AutoRest v3 generators")
          ),
          cm.createNode(
            "block_quote",
            cm.createNode(
              "paragraph",
              cm.createText("see https://aka.ms/autorest")
            )
          ),
          cm.createCodeBlock(
            "yaml $(enable-multi-api)",
            yaml.dump({ "input-file": it.toArray(set) }, { lineWidth: 1000 })
          )
        )
        const x = cm.markDownExToString({ markDown: readMeMulti })
        fs.writeFile(path.join(f.dir, "readme.enable-multi-api.md"), x)
      }
    }
  } catch (e) {
    console.error(e)
  }
}
github Azure / oav / lib / templates / yamlHttpTemplate.ts View on Github external
private getResponseHeaders(response: Response): string {
    let result = ``
    if (response.body) {
      result += `    Content-Length: ${JSON.stringify(response.body).length}\n`
    }
    let gotContentType = false
    if (response.headers) {
      const headers = toArray(keys(response.headers))
      for (let i = 0; i < headers.length; i++) {
        const headerName = headers[i]
        if (headerName.match(/^Content-Type$/gi) !== null) {
          gotContentType = true
        }
        result += `    ${headerName}: ${response.headers[headerName]}`
        if (i !== headers.length - 1) {
          result += `\n`
        }
      }
    }
    if (!gotContentType) {
      result += `    Content-Type: application/json; charset=utf-8`
    }
    return result
  }
github Azure / oav / lib / validators / specResolver.ts View on Github external
private setAdditionalPropertiesFalse(): void {
    const spec = this.specInJson
    const definitions = spec.definitions as DefinitionsObject

    for (const model of sm.values(definitions)) {
      if (
        !model.additionalProperties &&
        !(
          !model.properties ||
          (model.properties && toArray(sm.keys(model.properties)).length === 0)
        )
      ) {
        model.additionalProperties = false
      }
    }
  }
github Azure / oav / lib / templates / markdownHttpTemplate.ts View on Github external
private getRequestHeaders(): string {
    let result = ``
    if (this.request.body) {
      result += `Content-Length: ${JSON.stringify(this.request.body).length}\n`
    }
    if (this.request.headers) {
      const headers = toArray(keys(this.request.headers))

      for (let i = 0; i < headers.length; i++) {
        const headerName = headers[i]
        result += `${headerName}: ${this.request.headers[headerName]}`
        if (i !== headers.length - 1) {
          result += `\n`
        }
      }
    }
    return result
  }
github Azure / oav / lib / templates / yamlHttpTemplate.ts View on Github external
private getRequestHeaders(): string {
    let result = ``
    if (this.request.body) {
      result += `  Content-Length: ${JSON.stringify(this.request.body).length}\n`
    }
    if (this.request.headers) {
      const headers = toArray(keys(this.request.headers))

      for (let i = 0; i < headers.length; i++) {
        const headerName = headers[i]
        result += `  ${headerName}: ${this.request.headers[headerName]}`
        if (i !== headers.length - 1) {
          result += `\n`
        }
      }
    }
    return result
  }