Skip to content
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

Restore Prefer header functionality #118

Closed
yakovkhalinsky opened this issue Jan 16, 2016 · 3 comments
Closed

Restore Prefer header functionality #118

yakovkhalinsky opened this issue Jan 16, 2016 · 3 comments

Comments

@yakovkhalinsky
Copy link
Contributor

See PR #61

We've dropped this functionality at some point.

Need to restore the ability to force responses by HTTP code by using the Prefer:status=XXX in the header.

@yakovkhalinsky
Copy link
Contributor Author

ping @marcelogo 👯

@marcelogo
Copy link
Contributor

@yakovkhalinsky

Drakov supports this functionality. It is just the matter of having an example that uses the Prefer header.

### Retrieve from GET [GET]
First GET example with header 

+ Request

    + Headers

            Custom-header: First


+ Response 200 (application/json;charset=UTF-8)

    + Body

            {"first": "response"}

+ Request

    + Headers

            Custom-header: Second


+ Response 200 (application/json;charset=UTF-8)

    + Body

            {"second": "response"}

+ Request

    + Headers

            Prefer: status=400

+ Response 400 (application/json;charset=UTF-8)
Get examples with a specific status code (eg. 400)

    + Body

            {"error": "Bad request"}

In this example, whenever Drakov receives a GET request with Prefer header and value status=400 a response {"error": "Bad request"} will be sent back.

@senyor-developer
Copy link

The documentation says that it's still supported (Changing the API Blueprint adding a custom header does not count ;) )

The feature is very useful for client testing purpose only and does not force you to change the Blueprint, creating confusion confusion to the API users. I have also an example that I can't make it work also with this proposal:

## item [/item/{id}]

+ Parameters
    + id: 5000 (number, required) - Item ID

### DELETE an item [DELETE]

+ Request

    + Headers

            Accept: application/vnd.api+json;version=1

+ Response 204

+ Request

    + Headers
            Accept: application/vnd.api+json;version=1
            Prefer: status=404

+ Response 404 (application/json)

    + Body

            {
              "error": "Not Found",
              "type": 404,
              "message": "item not found" does not exists": ""
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants