Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a content-type on a POST request with no body in OpenAPI 3.0?

Tags:

openapi

I am trying to create an OpenAPI 3.0 definition for an existing API. It has a POST operation and takes header values as the input. Request body is empty. However the backend API was coded very poorly and is expecting request header Content-Type: application/json even though the body is empty.

How do I achieve this in OpenAPI 3.0? Looks like Content-Type is not accepted as a valid header parameter in OAS 3.0.

like image 493
Raj Sharma Avatar asked Nov 28 '25 14:11

Raj Sharma


1 Answers

You can add the requestBody with the application/json media type but no schema.

openapi: 3.0.2
...
paths:
  /something:
    post:
      parameters:
        ...
      requestBody:
        content:
          application/json: {}
like image 153
Helen Avatar answered Nov 30 '25 05:11

Helen