Skip to content
Closed
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
2 changes: 2 additions & 0 deletions lib/spec/openapi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ module.exports = function (opts, cache, routes, Ref, done) {
const serverUrls = resolveServerUrls(defOpts.servers)

for (const route of routes) {
if (route.websocket) continue

const transformResult = route.config?.swaggerTransform !== undefined
? route.config.swaggerTransform
? route.config.swaggerTransform({ schema: route.schema, url: route.url, route, openapiObject })
Expand Down
35 changes: 35 additions & 0 deletions test/spec/openapi/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,41 @@ test('route options - extension', async (t) => {
t.assert.deepEqual(definedPath['x-tension'], true)
})

test('route options - websocket', async (t) => {
t.plan(1)
const fastify = Fastify()

await fastify.register(fastifySwagger, openapiOption)

const opts = {
schema: {
operationId: 'websocket',
summary: 'Websocket route',
tags: ['tag'],
description: 'Route with websocket true',
servers: [
{
url: 'https://localhost'
}
],
externalDocs: {
description: 'Swagger',
url: 'https://swagger.io'
}
},
websocket: true
}

fastify.get('/', opts, () => {})

await fastify.ready()

const openapiObject = fastify.swagger()

const api = await Swagger.validate(openapiObject)
t.assert.strictEqual(api.paths['/'], undefined, 'no schema created when websocket route')
})

test('parses form parameters when all api consumes application/x-www-form-urlencoded', async (t) => {
t.plan(2)
const fastify = Fastify()
Expand Down