@fastify/swagger
Advanced tools
Comparing version 8.10.0 to 8.10.1
'use strict' | ||
const path = require('path') | ||
const fs = require('fs') | ||
const path = require('node:path') | ||
const fs = require('node:fs') | ||
const yaml = require('yaml') | ||
@@ -6,0 +6,0 @@ |
@@ -9,2 +9,3 @@ 'use strict' | ||
const sharedSchemasMap = new Map() | ||
let hookRun = false | ||
@@ -55,2 +56,3 @@ fastify.addHook('onRoute', (routeOptions) => { | ||
fastify.addHook('onReady', (done) => { | ||
hookRun = true | ||
const allSchemas = fastify.getSchemas() | ||
@@ -67,2 +69,5 @@ for (const schemaId of Object.keys(allSchemas)) { | ||
Ref () { | ||
if (hookRun === false) { | ||
throw new Error('.swagger() must be called after .ready()') | ||
} | ||
const externalSchemas = cloner(Array.from(sharedSchemasMap.values())) | ||
@@ -69,0 +74,0 @@ return Ref(Object.assign( |
'use strict' | ||
const fs = require('fs') | ||
const path = require('path') | ||
const fs = require('node:fs') | ||
const path = require('node:path') | ||
@@ -6,0 +6,0 @@ function readPackageJson () { |
{ | ||
"name": "@fastify/swagger", | ||
"version": "8.10.0", | ||
"version": "8.10.1", | ||
"description": "Serve Swagger/OpenAPI documentation for Fastify, supporting dynamic generation", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,1 +16,21 @@ 'use strict' | ||
}) | ||
test('fastify.swagger should throw if called before ready', async (t) => { | ||
t.plan(1) | ||
const fastify = Fastify() | ||
await fastify.register(fastifySwagger) | ||
t.throws(fastify.swagger.bind(fastify)) | ||
}) | ||
test('fastify.swagger should throw if called before ready (openapi)', async (t) => { | ||
t.plan(1) | ||
const fastify = Fastify() | ||
await fastify.register(fastifySwagger, { | ||
openapi: {} | ||
}) | ||
t.throws(fastify.swagger.bind(fastify)) | ||
}) |
'use strict' | ||
const path = require('path') | ||
const path = require('node:path') | ||
const { test } = require('tap') | ||
@@ -9,4 +9,4 @@ const Fastify = require('fastify') | ||
const Swagger = require('@apidevtools/swagger-parser') | ||
const readFileSync = require('fs').readFileSync | ||
const resolve = require('path').resolve | ||
const readFileSync = require('node:fs').readFileSync | ||
const resolve = require('node:path').resolve | ||
const yaml = require('yaml') | ||
@@ -13,0 +13,0 @@ |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
259842
7460
0