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

Set appropriate Accept header for Search clients #11562

Merged
merged 3 commits into from
Apr 28, 2020
Merged

Conversation

heaths
Copy link
Member

@heaths heaths commented Apr 24, 2020

Fixes #11532

@heaths
Copy link
Member Author

heaths commented Apr 24, 2020

@pakrym I had to switch the order of sanitizing variables and content so that we can properly capture which variables need to be sanitized from content.

@tg-msft @brjohnstmsft I noticed from some of the test recordings that when we get a SearchIndexClient from a SearchServiceClient, we "inherit" its HttpPipeline which still uses the "minimal" Accept header. I can fix this but need to make a few small refactorings. But it made me wonder if other languages have the same problem, and noticed that Python and JS don't have a getIndexClient method.

I noticed that Java may have the same problem, too, since it passes the pipeline. /cc @sima-zhu @alzimmermsft

@tg-msft
Copy link
Member

tg-msft commented Apr 24, 2020

Here's a transform that I think does what you're looking for:

Add Accept header

Return no metadata for /docs operations and minimal for the rest.

directive:
- from: swagger-document
  where: $.paths
  transform: >
    for (var path in $) {
      for (var opName in $[path]) {
        var op = $[path][opName];
        var accept = "application/json;odata.metadata=";
        accept += path.startsWith("/docs") ? "none" : "minimal";
        op.parameters.push({
          name: "Accept",
          "in": "header",
          required: true,
          type: "string",
          enum: [accept],
          "x-ms-parameter-location": "method"
        });
      }
    }
    return $;

Copy link
Member

@tg-msft tg-msft left a comment

Choose a reason for hiding this comment

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

Looks good!

@heaths heaths merged commit 7faf72e into Azure:master Apr 28, 2020
@heaths heaths deleted the issue11532 branch April 28, 2020 00:38
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

Successfully merging this pull request may close these issues.

SearchServiceClient needs to send odata.metadata in Accept request header
4 participants