Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KilianB opened this issue Oct 18, 2023 · 0 comments

Comments

@KilianB
Copy link

KilianB commented Oct 18, 2023

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.

elysia-swagger/src/index.ts

Lines 132 to 143 in 8eb03f0

routes.forEach((route: InternalRoute) => {
registerSchemaPath({
schema,
hook: route.hooks,
method: route.method,
path: route.path,
// @ts-ignore
models: app.definitions.type,
contentType: route.hooks.type
})
})
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant