seriousme / fastify-openapi-glue

A plugin for the Fastify webserver to autogenerate a Fastify configuration based on a OpenApi(v2/v3) specification.
MIT License
202 stars 34 forks source link

PARAMETERS method is not supported: when using cross-method parameters #504

Closed martijnimhoff closed 1 year ago

martijnimhoff commented 1 year ago

My issue is exactly like this issue: https://github.com/seriousme/fastify-openapi-glue/issues/52

However I'm using 4.3.0 of this library.

I can reproduce this issue with this swagger doc:

{
  "swagger": "2.0",
  "info": {
    "title": "example",
    "version": "v1"
  },
  "paths": {
    "/example/{id}": {
      "get": {
        "operationId": "example",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "type": "string"
        }
      ]
    }
  }
}

This results in this error:

FastifyError [Error]: PARAMETERS method is not supported.
    at normalizeAndValidateMethod (C:\Projects\486-gvn-nodejs-api\node_modules\fastify\lib\route.js:536:11)
    at Object.route (C:\Projects\486-gvn-nodejs-api\node_modules\fastify\lib\route.js:198:21)
    at Object._route [as route] (C:\Projects\486-gvn-nodejs-api\node_modules\fastify\fastify.js:280:27)
    at generateRoutes (file:///C:/Projects/486-gvn-nodejs-api/node_modules/fastify-openapi-glue/index.js:107:19)
    at Plugin.exec (C:\Projects\486-gvn-nodejs-api\node_modules\avvio\plugin.js:130:19)
    at Boot.loadPlugin (C:\Projects\486-gvn-nodejs-api\node_modules\avvio\plugin.js:272:10)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

Perhaps the issue got reintroduced somehow?

According to the specs, swagger 2.0 should support the parameters key: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#fixed-fields-4

martijnimhoff commented 1 year ago

I took a look at the source code. I see the parameters key was only implemented for v3. However it is actually also a valid spec for v2. Could that be added?

seriousme commented 1 year ago

Hi, thanks for asking!

It sounds like we should be able to add this to V2 as well however I 'm currently enjoying a vacation away from my Dev environment. I will look into the issue next week!

Kind regards, Hans

seriousme commented 1 year ago

Released as 4.3.1 on NPM. Enjoy !

Kind regards, Hans