-
Notifications
You must be signed in to change notification settings - Fork 6
docs(all): move use curl to call mock server #166
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
Merged
JLekawa
merged 9 commits into
main
from
18999-docs-move-use-curl-to-call-mock-server-to-end-user
Nov 10, 2025
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b975b6e
docs(all): move user curl to call mock server
JLekawa 93322e4
Merge branch 'main' into 18999-docs-move-use-curl-to-call-mock-server…
JLekawa 2ea195e
Merge branch 'main' into 18999-docs-move-use-curl-to-call-mock-server…
JLekawa da54035
Apply suggestions from code review
JLekawa 279de09
Merge branch 'main' into 18999-docs-move-use-curl-to-call-mock-server…
JLekawa f66c8f3
Apply suggestions from code review
JLekawa a270522
Apply suggestions from code review
JLekawa 04b98fb
Update docs/end-user/test-apis-replay.md
JLekawa 11c59f5
Merge branch 'main' into 18999-docs-move-use-curl-to-call-mock-server…
JLekawa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # Test APIs using CLI | ||
|
|
||
| Use the cURL app in a command-line interface (CLI) tool of your choice to make calls to APIs in your project. | ||
JLekawa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| You can send requests to servers listed on API documentation page, or to Redocly mock server. | ||
|
|
||
| ## Use cURL to call an API operation | ||
JLekawa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| To send an API request using cURL: | ||
JLekawa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. Go to the API documentation page for the operation you want to call. | ||
| 1. Copy the curl command from the code samples. | ||
| 1. (Optional) To change the server, scroll to the **Servers** section of the API documentation page, click the **Copy** icon next to a server URL, and paste the value into your command. | ||
| 1. Update the values in the curl command as needed. | ||
|
|
||
| For example: | ||
|
|
||
| ```curl {% title="cURL command to call Update special event operation" %} | ||
JLekawa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| curl -i -X PATCH \ | ||
| -u : \ | ||
| 'https://redocly.com/_mock/docs/openapi/museum-api/special-events/dad4bce8-f5cb-4078-a211-995864315e39' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "location": "Under the sea." | ||
| }' | ||
| ``` | ||
| 1. Run the curl command in a CLI tool. | ||
|
|
||
| The CLI tool outputs a response from the server. | ||
|
|
||
| ```bash cURL mock server response | ||
JLekawa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| HTTP/2 200 | ||
| access-control-allow-credentials: true | ||
| access-control-allow-headers: * | ||
| access-control-allow-methods: * | ||
| access-control-allow-origin: * | ||
| alt-svc: h3=":443"; ma=2592000 | ||
| content-type: application/json | ||
| date: Thu, 11 Jul 2024 17:24:24 GMT | ||
| server: Caddy | ||
| strict-transport-security: max-age=31536000; | ||
| x-content-type-options: nosniff | ||
| x-frame-options: deny | ||
| x-xss-protection: 1;mode=block; | ||
|
|
||
| {"eventId":"dad4bce8-f5cb-4078-a211-995864315e39","name":"Mermaid Treasure Identification and Analysis","location":"Under the sea.","eventDescription":"Join us as we review and classify a rare collection of 20 thingamabobs, gadgets, gizmos, whoosits, and whatsits, kindly donated by Ariel.","dates":["2023-09-05","2023-09-08"],"price":15}% | ||
| ``` | ||
|
|
||
| ## Return a specific response example | ||
|
|
||
| Force the Redocly mock server to respond with a specific example from the API description using the `x-redocly-response-body-example` header to pass the example's name. | ||
|
|
||
| The following example forces a response for a `general_entry` ticket from the Museum API's mock server: | ||
|
|
||
| ```curl | ||
| curl -i -X POST \ | ||
| -u : \ | ||
| https://redocly.com/_mock/docs/openapi/museum-api/tickets \ | ||
| -H 'x-redocly-response-body-example: general_entry' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "ticketType": "event", | ||
| "eventId": "dad4bce8-f5cb-4078-a211-995864315e39", | ||
| "ticketDate": "2023-09-05", | ||
| "email": "dave@example.com" | ||
| }' | ||
| ``` | ||
|
|
||
| The following example forces a response for an `event_entry` ticket from the Museum API's mock server: | ||
|
|
||
| ```curl | ||
| curl -i -X POST \ | ||
| -u : \ | ||
| https://redocly.com/_mock/docs/openapi/museum-api/tickets \ | ||
| -H 'x-redocly-response-body-example: event_entry' \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "ticketType": "general", | ||
| "ticketDate": "2023-09-07", | ||
| "email": "dave@example.com" | ||
| }' | ||
| ``` | ||
|
|
||
| {% admonition type="info" %} | ||
| If you call the Redocly mock server and no match is found for the named example passed in the header, the mock server, depending on its configuration, does one of the following: | ||
|
|
||
| - throws an error | ||
| - returns another example for that operation | ||
| {% /admonition %} | ||
|
|
||
| ## Resources | ||
|
|
||
| - [Interact with API documentation](./interact-with-api.md) | ||
| - [Test APIs using Replay](./test-apis-replay.md) | ||
| - [Use a classic catalog](./use-classic-catalog.md) | ||
| - Explore other ways you can interact with the [user interface](./index.md) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| # Test APIs using Replay | ||
|
|
||
| You can make API calls directly from the API reference documentation in your project. | ||
| Projects that contain API documentation, typically have a tool you can used to try out (test) API requests. | ||
| Make API calls directly from the API reference documentation in your project. | ||
| Projects that contain API documentation, typically have Replay - the tool you can use to try out (test) API requests. | ||
|
|
||
| Use Replay to: | ||
|
|
||
| - edit any field in sample requests, unrestricted by API description schemas | ||
| - save requests and view request history | ||
| - set up and use different environments with customizable variables | ||
|
|
@@ -19,15 +20,15 @@ Replay is split into two panels, **Request** and **History**. | |
|
|
||
| Alternatively, some documentation pages may have an embedded Replay console that is tied to a specific description file. | ||
|
|
||
| ## Use the Request panel | ||
| ## Use the Request pane | ||
|
|
||
| The Request panel is located on the left side of Replay and includes everything needed to make a request for an endpoint from your API description. | ||
| The Request pane is located on the left side of Replay and includes everything needed to make a request for an endpoint from your API description. | ||
|
|
||
| ### Send a sample request | ||
|
|
||
| To send a sample request, enter the required parameters and click the **Send** button. | ||
|
|
||
| ### Response panel | ||
| ### Response pane | ||
|
|
||
| After you have sent a sample request, a sample response displays in the bottom of the Request pane. | ||
|
|
||
|
|
@@ -38,7 +39,7 @@ The sample response is based on example responses included in your API descripti | |
| - response headers and values | ||
| - response cookies | ||
|
|
||
| Click the copy icon on the right side of the panel to copy the sample response. | ||
| Click the **Copy** icon on the right side of the pane to copy the sample response. | ||
|
|
||
| ## Work with environments | ||
|
|
||
|
|
@@ -60,10 +61,10 @@ To switch to a different environment: | |
| 1. In Replay's top-right corner, click the **Environments** icon. | ||
| 1. In the **Environments** window's bottom-left corner, click **New environment**. | ||
| 1. Enter a name for the environment and confirm. | ||
| 2. In the **Server** field, hover over **More options** and click **Edit**. | ||
| 3. Enter the server's URL and click **Save**. | ||
| 4. (Optional) Expand the **Server variable** field and enter values for server variables. | ||
| 5. (Optional) In the **Inputs** table you can: | ||
| 1. In the **Server** field, hover over **More options** and click **Edit**. | ||
| 1. Enter the server's URL and click **Save**. | ||
| 1. (Optional) Expand the **Server variable** field and enter values for server variables. | ||
| 1. (Optional) In the **Inputs** table you can: | ||
| - Add new inputs and their values. | ||
| - Edit values of existing inputs. | ||
| - Set inputs values to secret. | ||
|
|
@@ -78,10 +79,11 @@ You can edit user-created environments to better suit your needs: | |
| - To set values for server variables, expand the **Server variable** field and enter values for server variables. | ||
|
|
||
| In the **Inputs** table you can: | ||
| - Add new inputs and their values. | ||
| - Edit values of existing inputs. | ||
| - Set inputs values to secret. | ||
| - Delete user-added inputs. | ||
|
|
||
| - add new inputs and their values | ||
| - edit values of existing inputs. | ||
|
||
| - set input values to secret | ||
| - delete user-added inputs | ||
|
|
||
| ### Set an environment as active | ||
|
|
||
|
|
@@ -125,11 +127,11 @@ To delete the search history: | |
|
|
||
| - In the **History** panel, on the left side of the **Search** field, click the broom icon. | ||
|
|
||
| ### Collapse the history panel | ||
| ### Collapse the History panel | ||
|
|
||
| You can hide the history panel to make the pages better fit smaller screens. | ||
| You can hide the History panel to make the pages better fit smaller screens. | ||
|
|
||
| To collapse the history panel: | ||
| To collapse the History panel: | ||
|
|
||
| - In Replay's bottom-left corner, click the **Collapse panel** button. | ||
|
|
||
|
|
@@ -142,5 +144,6 @@ Otherwise, if you want to see the reference documentation, you can close Replay | |
| ## Resources | ||
|
|
||
| - [Interact with API documentation](./interact-with-api.md) | ||
| - [Test APIs using CLI](./test-apis-cli.md) | ||
| - [Use a classic catalog](./use-classic-catalog.md) | ||
| - Explore other ways you can interact with the [user interface](./index.md) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.