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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(javascript): use the text/plain content-type #614

Merged
merged 1 commit into from
May 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion templates/javascript/api-single.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function create{{capitalizedApiName}}(options: CreateClientOptions{{#hasR
requestsCache: options.requestsCache,
responsesCache: options.responsesCache,
baseHeaders: {
'content-type': 'application/x-www-form-urlencoded',
'content-type': 'text/plain',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably be enforced by a unit test (not sure where and how)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous version didn't seem tested either. An extra test per method checking it sends the right content type maybe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think CTS checks the headers but never really took a look at it. Pierre will have the answer 鈽猴笍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can test for headers but we don't actually use it yet, because it was the same everywhere, definitely the time to test it ! For example in tests/CTS/methods/requests/search/assignUserId.json we check the value of headers.x-algolia-user-id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is only done in the JS client (other clients always use application/json), and itself mostly for the browser (node could use application/json too), I couldn't find a good place for those tests

...auth.headers(),
},
baseQueryParameters: auth.queryParameters(),
Expand Down