docusaurus-openapi icon indicating copy to clipboard operation
docusaurus-openapi copied to clipboard

requestBody is not displayed

Open simranbentel opened this issue 4 years ago • 8 comments

On a post type endpoint, the schema of the requestBody is not being displayed.

Expected: requestBody content is displayed.

Actual: requestBody content is being ignored.

simranbentel avatar Dec 13 '21 19:12 simranbentel

This sounds like a bug. Do you mind sharing your OpenAPI definition and maybe a screenshot?

bourdakos1 avatar Dec 13 '21 19:12 bourdakos1

Here is the requestBody of an endpoint: Screen Shot 2021-12-13 at 12 02 02 PM

Here is the output missing the requestBody: 144742435-ff9c9d8f-803f-4178-84a8-83535971ef9d

simranbentel avatar Dec 13 '21 20:12 simranbentel

Okay, I think the issue here is that we don’t support “allOf” yet. I’ll look into seeing what that entails

bourdakos1 avatar Dec 14 '21 02:12 bourdakos1

@simranbentel do you mind testing to see if PR #96 fixes your request body issue?

bourdakos1 avatar Dec 14 '21 23:12 bourdakos1

@simranbentel do you mind testing to see if PR #96 fixes your request body issue?

Cloned your fork and checked out the branch. Works! RequestBody now displays for me. Thanks!

simranbentel avatar Dec 15 '21 19:12 simranbentel

@bourdakos1 I found a bug remaining with this issue. In the endpoints that use allOf, the ApiDemoPanel is not able to determine required RequestBody options. The current logic determines the body as optional always.

Screen Shot 2021-12-21 at 3 10 20 PM

simranbentel avatar Dec 21 '21 23:12 simranbentel

@simranbentel I am unable to reproduce the issue. The following OpenAPI definition:

openapi: 3.0.3
info:
  title: "Issue #91"
  version: 1.0.0
paths:
  /example:
    post:
      summary: Issue a new invoice
      description: Only fiat currencies which are available for the ...
      requestBody:
        required: true
        description: New invoice request
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/CreateInvoiceReq"
      responses:
        200:
          description: OK
components:
  schemas:
    CreateInvoiceReq:
      type: object
      properties:
        code:
          type: integer
          format: int32
        type:
          type: string
        message:
          type: string

Renders the following demo panel:

image

bourdakos1 avatar Jan 02 '22 04:01 bourdakos1

Hi @bourdakos1, seems like anyOf/oneOf is not supported either. It's very similar to this issue that I decided to just comment here instead of opening a new issue (let me know if you'd prefer otherwise).

There is an example in the official examples: https://docusaurus-openapi.netlify.app/petstore/get-user-by-user-name/ where the pet is using oneOf and it is not rendering anything: image

Would it be possible to "hack" a solution to support these two as well, like you did for the allOf?

pmilic021 avatar Apr 03 '23 14:04 pmilic021