Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <[email protected]>
  • Loading branch information
mcollina committed Nov 13, 2024
1 parent 71a653f commit 26c09fc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { readFileSync } from 'node:fs'
import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import Ajv04 from 'ajv-draft-04'
import addFormats from 'ajv-formats'
import Ajv2020 from 'ajv/dist/2020.js'
Expand All @@ -14,7 +15,7 @@ const ajvVersions = {
const inlinedRefs = 'x-inlined-refs'

function localFile (file) {
return new URL(file, import.meta.url).pathname
return fileURLToPath(new URL(file, import.meta.url))
}

function importJSON (file) {
Expand Down
5 changes: 3 additions & 2 deletions test/check-versions.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { strict as assert } from 'node:assert/strict'
import { createHash } from 'node:crypto'
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { readdir } from 'node:fs/promises'
import { test } from 'node:test'
import { Validator } from '../index.js'
import { Snapshot } from './snapshot.js'

const supportedVersions = Validator.supportedVersions

function localPath (path) {
return new URL(path, import.meta.url).pathname
function localPath (fileName) {
return fileURLToPath(new URL(fileName, import.meta.url))
}

const snapShotFile = localPath('snapshots-check-versions.json')
Expand Down
9 changes: 5 additions & 4 deletions test/validation-refs.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { strict as assert } from 'node:assert/strict'
import { test } from 'node:test'
import { fileURLToPath } from 'node:url'
import { Validator } from '../index.js'

function localFile (file) {
return new URL(file, import.meta.url).pathname
function localPath (fileName) {
return fileURLToPath(new URL(fileName, import.meta.url))
}

const invalidRefsSpec = localFile('./validation/invalid-refs.yaml')
const recursiveRefsSpec = localFile('./validation/openapi-recursive.v3.json')
const invalidRefsSpec = localPath('./validation/invalid-refs.yaml')
const recursiveRefsSpec = localPath('./validation/openapi-recursive.v3.json')

test('invalid refs in YAML fail validation', async (t) => {
const validator = new Validator()
Expand Down
5 changes: 3 additions & 2 deletions test/validation.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { strict as assert } from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { readFile } from 'node:fs/promises'
import { test } from 'node:test'
import { Validator } from '../index.js'

function localFile (file) {
return new URL(file, import.meta.url).pathname
function localFile (path) {
return fileURLToPath(new URL(path, import.meta.url))
}

function importJSON (file) {
Expand Down

0 comments on commit 26c09fc

Please sign in to comment.