json-schema-ref-parser Issue #93
const refParser = require('json-schema-ref-parser')
const mkdirp = require('mkdirp');
const path = require('path');
const fs = require('fs');
const schemaDir = '/G/code/git/vs-openapi-designer/test/resource/v2.0/yaml/issue_01';
mkdirp.sync(schemaDir);
const schemaFile = path.join(schemaDir, 'petstore.yaml');
console.log(schemaFile);
fs.writeFileSync(schemaFile, `
swagger: "2.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
host: petstore.swagger.io
basePath: /v1
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
/pets:
$ref: 'pets.yaml'
/pets/{petId}:
$ref: 'pets_petId.yaml'
definitions:
Pet:
properties:
id:
type: integer
format: int64
Error:
$ref: 'error.yaml'
`)
try {
let bundled = await refParser.bundle(schemaFile);
console.log(bundled);
}
catch (err) {
console.error(err);
}
no comments