@hyperone/cli-core
Advanced tools
Comparing version 1.0.16 to 1.0.17
import $RefParser from '@apidevtools/json-schema-ref-parser'; | ||
import fetch from 'node-fetch'; | ||
@@ -8,7 +7,12 @@ export const lazy_resolver = (baseUrl, options = {}) => ({ | ||
// TODO: Support extensions parameter | ||
read({ url /*, extensions */ }, callback) { | ||
read({ url/*, extensions */ }, callback) { | ||
return callback(null, async () => { | ||
const path = new URL(url, baseUrl).toString(); | ||
const resp = await fetch(path); | ||
const schema = await resp.json(); | ||
// json-schema-ref-parser is opinionated regarding environemnt | ||
// See https://github.com/APIDevTools/json-schema-ref-parser/blob/5674d1941042602d81165dbbd46879071d4af9ba/lib/index.js#L103 | ||
// https://github.com/APIDevTools/json-schema-ref-parser/blob/5674d1941042602d81165dbbd46879071d4af9ba/lib/util/url.js#L33 | ||
if (url.startsWith(process.cwd())) { | ||
url = url.replace(process.cwd(), '.'); | ||
} | ||
url = new URL(url, baseUrl).toString(); | ||
const schema = await $RefParser.parse(url); | ||
return $RefParser.dereference(schema, { | ||
@@ -15,0 +19,0 @@ resolve: { |
@@ -1,2 +0,1 @@ | ||
import fetch from 'node-fetch'; | ||
import $RefParser from '@apidevtools/json-schema-ref-parser'; | ||
@@ -14,11 +13,4 @@ import {lazy_resolver} from './json_schema'; | ||
init: async (options) => { | ||
let schema; | ||
const openapiUrl = options.openapiUrl || 'https://api.hyperone.com/v2/openapi.json'; | ||
if (options.openapiSpec) { | ||
schema = options.openapiSpec; | ||
} else { | ||
const resp = await fetch(openapiUrl); | ||
schema = await resp.json(); | ||
} | ||
const schema = await $RefParser.parse(options.openapiSpec || openapiUrl); | ||
Object.assign(spec, await $RefParser.dereference(schema, { | ||
@@ -25,0 +17,0 @@ resolve: { |
{ | ||
"name": "@hyperone/cli-core", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"@apidevtools/json-schema-ref-parser": "^9.0.3", | ||
"@hyperone/cli-framework": "^1.0.12", | ||
"@hyperone/cli-framework": "^1.0.17", | ||
"camel-case": "^4.1.1", | ||
@@ -30,3 +30,3 @@ "command-line-args": "^5.1.1", | ||
"license": "MIT", | ||
"gitHead": "f965f99bb528f0d8a3aa513fe37d64627c6361d9" | ||
"gitHead": "596e620b30d7431c04af75d402f5f986e1569c34" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26671
1
665