You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Request Body objects have a required property (defaulting to false) that indicates whether a request body is allowed to be empty. As far as I can tell, the value of required isn't represented anywhere in the generated documentation for an operation.
Context
This makes the documentation for my API less clear, because downstream consumers e.g. assume they can safely omit a request body when that will actually cause errors.
Current Behavior
If an operation doesn't have required on its requestBody set, or has required: false, the "Body" section looks like this:
Setting required: true in the requestBody yields the exact same result.
Expected Behavior
There should be some indication that the request body is required, e.g. an orange "required" marker next to the "Body" heading, similar to how required fields on object schemas are marked.
Possible Workaround/Solution
The required status of a request body can be manually documented in e.g. the description of the request body, but that's error prone, and also plain annoying given the information is already there in the input YAML itself.
Steps to Reproduce
Create index.html with the following contents:
<!doctype html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><title>Elements in HTML</title><scriptsrc="https://unpkg.com/@stoplight/elements/web-components.min.js"></script><linkrel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css"></head><body><elements-apiapiDescriptionUrl="api.yaml"
router="hash"
/></body></html>
Create api.yaml in the same directory with the following contents:
openapi: 3.0.3info:
title: Test APIdescription: Test APIversion: 1.0.0paths:
/test:
post:
requestBody:
content:
application/json:
schema:
type: objectproperties:
foo:
type: string
Serve the directory, e.g. using python3 -m http.server and view the page for POST /test.
Add required: true to the requestBody.
Refresh the page.
Environment
Version used: Whatever is latest on unpkg.com CDN
Environment name and version (e.g. Chrome 39, node.js 5.4): Firefox 103.0.2 (64-bit)
Operating System and version (desktop or mobile): Ubuntu 22.04
Link to your environment/workspace/project: N/A
The text was updated successfully, but these errors were encountered:
Request Body objects have a
required
property (defaulting tofalse
) that indicates whether a request body is allowed to be empty. As far as I can tell, the value ofrequired
isn't represented anywhere in the generated documentation for an operation.Context
This makes the documentation for my API less clear, because downstream consumers e.g. assume they can safely omit a request body when that will actually cause errors.
Current Behavior
If an operation doesn't have
required
on itsrequestBody
set, or hasrequired: false
, the "Body" section looks like this:Setting
required: true
in therequestBody
yields the exact same result.Expected Behavior
There should be some indication that the request body is required, e.g. an orange "required" marker next to the "Body" heading, similar to how required fields on object schemas are marked.
Possible Workaround/Solution
The required status of a request body can be manually documented in e.g. the
description
of the request body, but that's error prone, and also plain annoying given the information is already there in the input YAML itself.Steps to Reproduce
Create
index.html
with the following contents:Create
api.yaml
in the same directory with the following contents:Serve the directory, e.g. using
python3 -m http.server
and view the page forPOST /test
.Add
required: true
to therequestBody
.Refresh the page.
Environment
The text was updated successfully, but these errors were encountered: