Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do BOM stripping for remote URL's #267

Merged
merged 1 commit into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 06/26/2018 0.4.51
- Bug fix: Do BOM stripping for remote URL's [#266](https://github.com/Azure/oav/issues/266).

### 06/20/2018 0.4.50
- Replace sway dependency with yasway.

### 06/19/2018 0.4.49
- Bug fix: Data is valid against more than one schema from `oneOf` [#248](https://github.com/Azure/oav/pull/248)
The problem occurs when referenced model may also accept `null`. The fix is replacing `oneOf` with `anyOf`.
Expand Down
7 changes: 4 additions & 3 deletions lib/util/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function parseJson(specPath: string): Promise<Spec> {
} else {
// local filepath
try {
const fileContent = stripBOM(fs.readFileSync(specPath, "utf8"))
const fileContent = fs.readFileSync(specPath, "utf8")
const result = parseContent(specPath, fileContent)
docCache[specPath] = Promise.resolve(result)
return result
Expand All @@ -101,10 +101,11 @@ export async function parseJson(specPath: string): Promise<Spec> {
*/
export function parseContent(filePath: string, fileContent: string): Spec {
let result = null
const sanitizedContent = stripBOM(fileContent)
if (/.*\.json$/ig.test(filePath)) {
result = JSON.parse(fileContent)
result = JSON.parse(sanitizedContent)
} else if (/.*\.ya?ml$/ig.test(filePath)) {
result = YAML.safeLoad(fileContent)
result = YAML.safeLoad(sanitizedContent)
} else {
const msg =
`We currently support "*.json" and "*.yaml | *.yml" file formats for validating swaggers.\n` +
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oav",
"version": "0.4.50",
"version": "0.4.51",
"author": {
"name": "Microsoft Corporation",
"email": "[email protected]",
Expand Down