Reputation: 471
I'm using Swagger UI to create the docs for a custom REST API.
I disabled the "Try it out" button since I don't want it, but I would love to show the curl command of every request.
Is there a way to show it without activating the "try it out" button? Or maybe add something in the YAML file that shows one more div with custom text in it?
Upvotes: 5
Views: 6819
Reputation: 97677
Is there a way to show it without activating the "try it out" button?
No. Swagger UI's curl command generator depends on "try it out" availability, because the commands are generated based on the specific parameter values that the user specified during "try it out".
Or maybe add something in the YAML file that shows one more div with custom text in it?
You can add use the description
field of operations to add details, such as code examples. Descriptions support Markdown for rich text formatting.
paths:
/something:
get:
summary: Get something
description: >-
Detailed description goes here.
And here's some code:
curl https://example.com/something -H "Accept: application/json"
responses:
200:
description: Successful response
Upvotes: 5