Conversation
|
Chatted with @imran-iq offline and he clarified that we'd like to move away from swagger docs anyway. Rather than adding support here we can revisit adding support to the connect DSL in the future. Since other example support was already delivered I'm going to close this PR. |
|
Quote:
The above does not give the desired result. It doesn't give you the nice dropdown. You're defining the requestBody:
content:
application/json:
schema:
examples:
Access token:
client_id: 'blah etc'where See chapter Request Body Examples here: https://swagger.io/docs/specification/describing-request-body/ In other words, this is what you want requestBody:
content:
application/json:
examples:
Access token:
value:
client_id: 'blah etc'
schema:where That does give you the nice dropdown. As far as I know there NO WAY to achieve this using rswag at the moment. |

A PR WITH EXAMPLE USAGE IS HERE: https://github.com/instacart/carrot/pull/155131
We want to add
examplessupport to request bodies in Swagger. Right now our requests look like the following:They just supply the type information in the field.
rswag does not support adding examples right now:
rswag#380
This PR adds some basic support for examples. It doesn't provide validation of examples. This is meant to be an initial implementation that we can add additional functionality to later if we need it.
With this change we now have the ability to call
within the body of an rspec test in order to bind an example to the request.
You can also bind multiple examples by calling
request_body_examplemultiple timesThe
summaryis what appears in the dropdown seen in the image below.By default, the
summaryis the summary defined by the rpec test when defining themethod:Eg, for
The summary would be
Error a vendor taskLastly - this PR only supports static "values". Eg, you cannot reference a
let (:body) { ... }it must bebody = {}.This is because I want to reduce the confusion if someone starts modifying the
bodyobject in nestedcontextsand ends up with a. bunch of "examples" that all have the same summary but different values.