cdimascio / express-openapi-validator

🦋 Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.x specification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to specify middleware handler for single endpoint

memen45 opened this issue · comments

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().

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