elysiajs / elysia-swagger

A plugin for Elysia to auto-generate Swagger page
MIT License
90 stars 46 forks source link

Routes registered with app.all are not correctly expanded in the swagger file #47

Closed KilianB closed 3 months ago

KilianB commented 1 year ago

When registering a route with the all method the generated swagger blindly copies the httpMethod which is not valid according to openapi 3.0.3 spec.

app
  .use(swagger())
  .all("test",() => {});
  "/test": {
    "all": {
      "operationId": "allTest",
        "responses": {
          "200": {}
        }
      }
  },

The only valid methods are get, put, post, delete, options, head, path, trace https://swagger.io/specification/

Here we probably should filter by valid methods and in case of all call the register function multiple times.

https://github.com/elysiajs/elysia-swagger/blob/8eb03f05cf87881b2ccb62ca761bacbea31faf4d/src/index.ts#L132-L143