本文整理匯總了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) {