Skip to content
Merged
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
19 changes: 13 additions & 6 deletions packages/massimo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,9 @@ async function buildCallFunction (
queryParser,
bodyTimeout,
headersTimeout,
dispatcher
dispatcher,
ajv
) {
if (validateResponse) {
await $RefParser.dereference(spec)
}
const ajv = new Ajv()
const url = new URL(baseUrl)
method = method.toUpperCase()
path = join(url.pathname, path)
Expand Down Expand Up @@ -447,6 +444,11 @@ export async function buildOpenAPIClient (options, openTelemetry) {
}

const generatedOperationIds = new Set()
let ajv
if (validateResponse) {
ajv = new Ajv()
}
let specDereferenced = false
for (const path of Object.keys(spec.paths)) {
const pathMeta = spec.paths[path]
let commonParameters = []
Expand All @@ -472,6 +474,10 @@ export async function buildOpenAPIClient (options, openTelemetry) {
}

client[kOperationIdMap][operationId] = { path, method }
if (validateResponse && !specDereferenced) {
await $RefParser.dereference(spec)
specDereferenced = true
}
client[operationId] = await buildCallFunction(
spec,
baseUrl,
Expand All @@ -485,7 +491,8 @@ export async function buildOpenAPIClient (options, openTelemetry) {
queryParser,
bodyTimeout,
headersTimeout,
dispatcher
dispatcher,
ajv
)
}
}
Expand Down