Example support for requests
See original GitHub issueIs your feature request related to a problem? Please describe. I want to add examples for requests (just like they have in postman) to showcase the expected responses, when sharing with a team. This gives a place to share, modify and improve the responses a lot. This is usually the case when APIs are being discussed and designed, before the actual development.
This will also help generate expected openapi response definitions (using oneOf
) from the pool of examples I have for a request.
Describe the solution you’d like Request can have an additional tab, called “examples” where I can input:
- expected response HTTP status code (eg. 200)
- expected response content type
- expected response body (using the code editor) as raw text
It should allow me to add as many examples as I can add. For each status codes, I can have multiple examples (which is highly unusual when json schema differs, but why not).
Describe alternatives you’ve considered
I’ve been relying on json schema to convert responses to their json schema, adding them to openapi as schemas and referencing them to responses
manually.
Additional context
I’ve prepared a pull request, which allows me to do so. Although, the UI is not appealing, yet it showcases a basic working prototype. Since I’ve add examples
as a attribute to the request
object, it happens to get synced automatically, without breaking anything.
List of examples
Adding example
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
@develohpanda I’ve added a draft PR for review. Will add tests if everything looks good
That sounds good. From an interface standpoint, it would be nice to define the tabs via a
requestTabs
array exported from the plugin, similar to how thedocumentActions
andworkspaceActions
one works.Feel free to reach out to me on Slack if you need any assistance, and/or create draft PRs for early reviews, so you don’t end up working too deep on an approach and have to then rework. 😄