From 7dadcff1b5ee976c381a81415ec2a03cdbfbb5ab Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 17 Aug 2026 09:36:53 +0100 Subject: [PATCH] feat(http): support for http QUERY --- packages/massimo-cli/package.json | 4 ++-- packages/massimo/index.js | 3 ++- packages/massimo/package.json | 2 +- .../test/fixtures/no-bodies/openapi.json | 18 ++++++++++++++++++ .../test/fixtures/no-bodies/plugins/example.js | 3 ++- packages/massimo/test/openapi.2.test.js | 3 +++ pnpm-lock.yaml | 4 ++-- 7 files changed, 30 insertions(+), 7 deletions(-) diff --git a/packages/massimo-cli/package.json b/packages/massimo-cli/package.json index 816b069..a030b0c 100644 --- a/packages/massimo-cli/package.json +++ b/packages/massimo-cli/package.json @@ -33,12 +33,12 @@ "homepage": "https://github.com/platformatic/massimo#readme", "dependencies": { "@fastify/error": "^4.0.0", - "massimo": "workspace:*", "camelcase": "~6.3.0", "code-block-writer": "^13.0.1", "graphql": "^16.8.1", "help-me": "^5.0.0", "jsonpointer": "^5.0.1", + "massimo": "workspace:*", "minimist": "^1.2.8", "pino": "^9.9.0", "pino-pretty": "^13.0.0", @@ -61,7 +61,7 @@ "dotenv": "^16.4.5", "eslint": "9", "execa": "^9.0.0", - "fastify": "^5.0.0", + "fastify": "^5.12.0", "fastify-tsconfig": "^3.0.0", "fs-extra": "^11.2.0", "neostandard": "^0.13.0", diff --git a/packages/massimo/index.js b/packages/massimo/index.js index a7bf5fc..b15741b 100644 --- a/packages/massimo/index.js +++ b/packages/massimo/index.js @@ -62,7 +62,8 @@ async function buildCallFunction ( method = method.toUpperCase() path = join(url.pathname, path) - const canHaveBody = method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'OPTIONS' + const bodyMethods = ['POST', 'PUT', 'PATCH', 'OPTIONS', 'QUERY'] + const canHaveBody = bodyMethods.includes(method) const pathParams = methodMeta.parameters?.filter(p => p.in === 'path') || [] const queryParams = methodMeta.parameters?.filter(p => p.in === 'query') || [] const headerParams = methodMeta.parameters?.filter(p => p.in === 'header') || [] diff --git a/packages/massimo/package.json b/packages/massimo/package.json index 1cf8e16..bf58413 100644 --- a/packages/massimo/package.json +++ b/packages/massimo/package.json @@ -52,7 +52,7 @@ "cleaner-spec-reporter": "^0.5.0", "eslint": "9", "execa": "^9.0.0", - "fastify": "^5.0.0", + "fastify": "^5.12.0", "neostandard": "^0.13.0", "tsd": "^0.33.0", "typescript": "^5.4.2" diff --git a/packages/massimo/test/fixtures/no-bodies/openapi.json b/packages/massimo/test/fixtures/no-bodies/openapi.json index 0b9826b..6531820 100644 --- a/packages/massimo/test/fixtures/no-bodies/openapi.json +++ b/packages/massimo/test/fixtures/no-bodies/openapi.json @@ -134,6 +134,24 @@ } } }, + "query": { + "operationId": "queryHello", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "foo": { "type": "string" }, + "bar": { "type": "string" } + } + } + } + } + } + } + }, "trace": { "operationId": "traceHello", "parameters": [], diff --git a/packages/massimo/test/fixtures/no-bodies/plugins/example.js b/packages/massimo/test/fixtures/no-bodies/plugins/example.js index bb11080..9a2adf6 100644 --- a/packages/massimo/test/fixtures/no-bodies/plugins/example.js +++ b/packages/massimo/test/fixtures/no-bodies/plugins/example.js @@ -27,7 +27,8 @@ module.exports = async function (fastify, opts) { 'DELETE', 'HEAD', 'OPTIONS', - 'TRACE' + 'TRACE', + 'QUERY' ], handler: returnRequestBody }) diff --git a/packages/massimo/test/openapi.2.test.js b/packages/massimo/test/openapi.2.test.js index 0495468..08fb098 100644 --- a/packages/massimo/test/openapi.2.test.js +++ b/packages/massimo/test/openapi.2.test.js @@ -504,6 +504,9 @@ test('do not set bodies for methods that should not have them', async t => { const optionsResult = await client.optionsHello(requestBody) deepEqual(optionsResult, requestBody) + const queryResult = await client.queryHello(requestBody) + deepEqual(queryResult, requestBody) + // https://www.rfc-editor.org/rfc/rfc9110 // MUST NOT send content const traceResult = await client.traceHello(requestBody) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dd7a37a..72769fd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -61,7 +61,7 @@ importers: specifier: ^9.0.0 version: 9.6.1 fastify: - specifier: ^5.0.0 + specifier: ^5.12.0 version: 5.12.0 neostandard: specifier: ^0.13.0 @@ -158,7 +158,7 @@ importers: specifier: ^9.0.0 version: 9.6.1 fastify: - specifier: ^5.0.0 + specifier: ^5.12.0 version: 5.12.0 fastify-tsconfig: specifier: ^3.0.0