cdimascio / express-openapi-validator

🦋 Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.x specification
MIT License
920 stars 211 forks source link

How to specify middleware handler for single endpoint #864

Closed memen45 closed 10 months ago

memen45 commented 1 year ago

The following two example endpoints in JS use different middleware:

app.get(
  '/api/endpoint1',
  express.json(),
  Routes.endpoint1_handler
);
app.post(
  '/api/endpoint2',
  express.raw({ type: "application/json" }),
  Routes.endpoint2
);

I would like to achieve the same using the express-openapi-validator, however, it seems like only endpoint 1 is working. What should be added to the api.yml to make endpoint2 work as well?

I have tried to set the requestBody schema for endpoint 2, but it still uses express.json().

cdimascio commented 10 months ago

This question is best for stack overflow. That said, both apis must be modeled within the oas spec. Include the expected content type and models