Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicate whether request body is required #1070

Closed
cmeeren opened this issue Oct 16, 2019 · 0 comments · Fixed by #2175
Closed

Indicate whether request body is required #1070

cmeeren opened this issue Oct 16, 2019 · 0 comments · Fixed by #2175
Assignees

Comments

@cmeeren
Copy link

cmeeren commented Oct 16, 2019

Currently, the requestBody's required attribute is not rendered:

      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: string

image

There should be an indicator for a required request body.

Furthermore, I suggest that to avoid confusion, optional request bodies are labelled explicitly as optional (perhaps only when adding an explicit requried: false?). This is because it's easy to confuse whether the request body is required with whether the attributes of a top-level object is required. For example:

requestBody:
  required: false
  content:
    application/json:
      schema:
        type: object
        required:
          - data
        properties:
          data:
            type: string

image

As rendered, I would expect the API to require a request body containing an object with the data attribute. However, the API requires EITHER an empty request body OR an object with the data attribute. An explicit optional indicator at the request body level could alleviate this confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants