本文整理汇总了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;
}
示例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();
});
});
示例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') || ''
}
}
示例4: loadDocumentSync
export function loadDocumentSync(file: string): any {
return YAML.load(file);
}
示例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) {