Skip to content

Commit

Permalink
Updated README.md with new headers
Browse files Browse the repository at this point in the history
  • Loading branch information
abhisheksarka committed Sep 8, 2024
1 parent 25e3de2 commit e10d24d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ my_rails_app/
**APICraft** dynamically generates mock APIs by interpreting contract specifications on the fly. You can request the mock response by passing `Apicraft-Mock: true` in the headers.

`https://yoursite.com/api/orders`
```
headers: {
Apicraft-Mock: true
}
```
```json
[
{
Expand All @@ -116,12 +121,12 @@ my_rails_app/
]
```

The above is an example of a 200 response. If you have more responses documented you can force that behaviour using `Apicraft-ResponseCode` header in the mock request.
The above is an example of a 200 response. If you have more responses documented you can force that behaviour using `Apicraft-Response-Code` header in the mock request.

`https://yoursite.com/api/orders`
```
headers: {
Apicraft-ResponseCode: 400
Apicraft-Response-Code: 400
Apicraft-Mock: true
}
```
Expand All @@ -133,9 +138,15 @@ headers: {
```

### 👀 API Introspection
All APIs are can be introspected at `https://yoursite.com/apicraft/*`. You need to append the API path that you are looking for.
All APIs are can be introspected. You can do so by passing the `Apicraft-Introspection` header.

```
headers: {
Apicraft-Introspection: true
}
```

Example: `https://yoursite.com/apicraft/api/orders`
Example: `https://yoursite.com/api/orders`
```json
{
"summary": "Retrieve a list of orders",
Expand Down Expand Up @@ -195,8 +206,8 @@ Apicraft.configure do |config|
config.headers = {
# The name of the header used to control
# the response code of the mock
# Defaults to Apicraft-ResponseCode
response_code: "Apicraft-ResponseCode",
# Defaults to Apicraft-Response-Code
response_code: "Apicraft-Response-Code",

# The name of the header to introspect the API.
# Defaults to Apicraft-Introspect
Expand Down
2 changes: 1 addition & 1 deletion lib/apicraft/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Config
DEFAULTS = {
contracts_path: nil,
headers: {
response_code: "Apicraft-ResponseCode",
response_code: "Apicraft-Response-Code",
introspect: "Apicraft-Introspect",
mock: "Apicraft-Mock",
content_type: "Content-Type"
Expand Down

0 comments on commit e10d24d

Please sign in to comment.