Forum Discussion

bdipasca's avatar
bdipasca
New Contributor
5 years ago

How to add a JSON example in a POST Request Body? (without a schema reference)

I came across this spec example on the OpenAPI Spec Github where there is a JSON example pasted directly into the GET response:   Is it possible to do something similar for the POST request b...
  • HKosova's avatar
    5 years ago

    Hi bdipasca,

    You can add examples for the request bodies too, but please also add a "schema":

          requestBody:
            content:
              application/json:
                schema:       # <-------
                  type: object
                examples:
                  foo:
                    value:
                      ...

     

    There's a known issue where examples cannot be rendered if "schema" isn't provided.