當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript yamljs.load函數代碼示例

本文整理匯總了TypeScript中yamljs.load函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript load函數的具體用法?TypeScript load怎麽用?TypeScript load使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了load函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: loadSwaggerDocument

 private static loadSwaggerDocument(options: SwaggerOptions) {
     let swaggerDocument: any;
     if (_.endsWith(options.filePath, '.yml') || _.endsWith(options.filePath, '.yaml')) {
         swaggerDocument = YAML.load(options.filePath);
     }
     else {
         swaggerDocument = fs.readJSONSync(options.filePath);
     }
     return swaggerDocument;
 }
開發者ID:thiagobustamante,項目名稱:typescript-rest,代碼行數:10,代碼來源:server.ts

示例2: express

 return new Promise<void>((resolve, reject) => {
     const app: express.Application = express();
     app.set('env', 'test');
     swaggerFile = YAML.load('./test/data/swagger.yaml');
     Server.swagger(app, {
         endpoint: 'api-docs',
         filePath: './test/data/swagger.yaml',
         host: 'localhost:5674',
         schemes: ['http']
     });
     server = app.listen(5674, (err: any) => {
         if (err) {
             return reject(err);
         }
         resolve();
     });
 });
開發者ID:thiagobustamante,項目名稱:typescript-rest,代碼行數:17,代碼來源:swagger.spec.ts

示例3: loadConfiguration

export function loadConfiguration(
  configFilePath: string,
  cmdlineArgs: CliArgTypes
): Configuration {
  let fileData: any = {}
  if (configFilePath) {
    debug(`loading configuration file: ${configFilePath}`)
    fileData = YAML.load(configFilePath) || {}
  }
  debug(`configuration file data: ${JSON.stringify(this.fileData)}`)

  function get(attributeName: string): string {
    const camelized = camelCase(attributeName)
    return (
      cmdlineArgs[attributeName] ||
      fileData[camelized] ||
      defaultValues[camelized]
    )
  }

  return {
    FormatterClass: getFormatterClass(
      get('format'),
      defaultValues.FormatterClass
    ),
    actions: fileData.actions ? fileData.actions : defaultValues.actions,
    classPrefix: get('class-prefix'),
    defaultFile: get('default-file'),
    exclude: get('exclude'),
    fileGlob: get('files') || defaultValues.fileGlob,
    keepTmp: String(get('keep-tmp')) === 'true',
    offline: String(get('offline')) === 'true',
    publications:
      Publications.fromJSON(fileData.publications || []).sorted() ||
      defaultValues.publications,
    sourceDir: get('source-dir'),
    useSystemTempDirectory: String(get('use-system-temp-directory')) === 'true',
    workspace: get('workspace') || ''
  }
}
開發者ID:Originate,項目名稱:tutorial-runner,代碼行數:40,代碼來源:load-configuration.ts

示例4: loadDocumentSync

export function loadDocumentSync(file: string): any {
  return YAML.load(file);
}
開發者ID:carlansley,項目名稱:swagger2,代碼行數:3,代碼來源:document.ts

示例5: function

interface Case {
  name: string;
  description: string;
  input: string;
  output: string;
  errors: string[];
  warnings?: string[];
  infos?: string[];
  sourceMap: number[];
}

declare global {
  export var __dirname: string;
}

let cases: Case[] = YAML.load(require('path').join(__dirname, 'cases.yaml'));

describe('Parser', function() {
  it('parses classes', function() {
    let index = 0;
    for (let testCase of cases) {
      index++;
      let parsed = parser.parse(testCase.input);
      let cuVisitor = new CUVisitor(null);
      let result = cuVisitor.visit(parsed);

      expect(result).to.equal(testCase.output, `Test (${index}) - ${testCase.name}\n`);

      if (testCase.warnings) {
        expect(testCase.warnings.length).to.equal(Visitor.handler.warnings.length);
        for (let warning of testCase.warnings) {
開發者ID:tomitrescak,項目名稱:Transpiler,代碼行數:31,代碼來源:cu_visitor_test.ts


注:本文中的yamljs.load函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。