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

Is PATCH supported by Swashbuckle? #595

Closed
ghost opened this issue Jan 8, 2016 · 1 comment
Closed

Is PATCH supported by Swashbuckle? #595

ghost opened this issue Jan 8, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Jan 8, 2016

Hi there,
I tried to use PATCH with Swashbuckle and noticed that generated Curl code contains wrong Content-Type field in the header:
curl -X PATCH --header "Content-Type: application/json" --header "Accept: application/json" -d "{
"Operations": [
{
"value": "UPDATED COMMENTS",
"path": "/comments",
"op": "replace",
}
]
}" "http://170.28.8.137/accounts/X23456"

Shouldn't be "Content-Type: application/json-patch" instead of "Content-Type: application/json"?
Thanks.

@domaindrivendev
Copy link
Owner

The "json-patch" media type is a specific JSON format for applying changes to a resource as an array of patch operations. It should be used in combination with the PATCH verb but the use of PATCH on it's own does NOT imply that media-type.

If your operation supports this format, then you need to add it to WebApi as a "custom media formatter" - http://www.asp.net/web-api/overview/formats-and-model-binding/media-formatters

If you do this correctly, then Swashbuckle and hence Swagger will describe the operation with the correct media type.

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

No branches or pull requests

1 participant