Skip to content

Commit

Permalink
Merge pull request #76 from martincostello/Schema-Tidy-Up
Browse files Browse the repository at this point in the history
Schema tidy-up
  • Loading branch information
martincostello authored Mar 16, 2019
2 parents 398f9a5 + 5bdff3a commit 3894821
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ The repository is hosted in [GitHub](https://github.com/justeat/httpclient-inter

## Building and Testing

Compiling the library yourself requires Git and the [.NET Core SDK](https://www.microsoft.com/net/download/core "Download the .NET Core SDK") to be installed (version 2.2.104 or later).
Compiling the library yourself requires Git and the [.NET Core SDK](https://www.microsoft.com/net/download/core "Download the .NET Core SDK") to be installed (version 2.2.105 or later).

To build and test the library locally from a terminal/command-line, run one of the following set of commands:

Expand Down
1 change: 1 addition & 0 deletions samples/SampleApp/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
Expand Down
24 changes: 11 additions & 13 deletions src/HttpClientInterception/HttpRequestInterceptionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ public HttpRequestInterceptionBuilder WithContentStream(Func<Task<Stream>> conte
/// <returns>
/// The current <see cref="HttpRequestInterceptionBuilder"/>.
/// </returns>
public HttpRequestInterceptionBuilder WithContentHeader(string name, string value) => WithContentHeader(name, new[] { value });
public HttpRequestInterceptionBuilder WithContentHeader(string name, string value)
=> WithContentHeader(name, new[] { value });

/// <summary>
/// Sets a custom HTTP content header to use with multiple values.
Expand All @@ -325,9 +326,7 @@ public HttpRequestInterceptionBuilder WithContentStream(Func<Task<Stream>> conte
/// The current <see cref="HttpRequestInterceptionBuilder"/>.
/// </returns>
public HttpRequestInterceptionBuilder WithContentHeader(string name, params string[] values)
{
return WithContentHeader(name, values as IEnumerable<string>);
}
=> WithContentHeader(name, values as IEnumerable<string>);

/// <summary>
/// Sets a custom HTTP content header to use with multiple values.
Expand Down Expand Up @@ -401,7 +400,8 @@ public HttpRequestInterceptionBuilder WithContentHeaders(IDictionary<string, str
/// <returns>
/// The current <see cref="HttpRequestInterceptionBuilder"/>.
/// </returns>
public HttpRequestInterceptionBuilder WithResponseHeader(string name, string value) => WithResponseHeader(name, new[] { value });
public HttpRequestInterceptionBuilder WithResponseHeader(string name, string value)
=> WithResponseHeader(name, new[] { value });

/// <summary>
/// Sets a custom HTTP response header to use with multiple values.
Expand All @@ -412,9 +412,7 @@ public HttpRequestInterceptionBuilder WithContentHeaders(IDictionary<string, str
/// The current <see cref="HttpRequestInterceptionBuilder"/>.
/// </returns>
public HttpRequestInterceptionBuilder WithResponseHeader(string name, params string[] values)
{
return WithResponseHeader(name, values as IEnumerable<string>);
}
=> WithResponseHeader(name, values as IEnumerable<string>);

/// <summary>
/// Sets a custom HTTP response header to use with multiple values.
Expand Down Expand Up @@ -500,7 +498,8 @@ public HttpRequestInterceptionBuilder WithMediaType(string mediaType)
/// <returns>
/// The current <see cref="HttpRequestInterceptionBuilder"/>.
/// </returns>
public HttpRequestInterceptionBuilder WithStatus(int statusCode) => WithStatus((HttpStatusCode)statusCode);
public HttpRequestInterceptionBuilder WithStatus(int statusCode)
=> WithStatus((HttpStatusCode)statusCode);

/// <summary>
/// Sets HTTP status code for the response.
Expand Down Expand Up @@ -638,7 +637,8 @@ public HttpRequestInterceptionBuilder HavingPriority(int? priority)
/// <remarks>
/// HTTP request headers are only tested for interception if the URI requested was registered for interception.
/// </remarks>
public HttpRequestInterceptionBuilder ForRequestHeader(string name, string value) => ForRequestHeader(name, new[] { value });
public HttpRequestInterceptionBuilder ForRequestHeader(string name, string value)
=> ForRequestHeader(name, new[] { value });

/// <summary>
/// Sets an HTTP request header to intercept with multiple values.
Expand All @@ -652,9 +652,7 @@ public HttpRequestInterceptionBuilder HavingPriority(int? priority)
/// HTTP request headers are only tested for interception if the URI requested was registered for interception.
/// </remarks>
public HttpRequestInterceptionBuilder ForRequestHeader(string name, params string[] values)
{
return ForRequestHeader(name, values as IEnumerable<string>);
}
=> ForRequestHeader(name, values as IEnumerable<string>);

/// <summary>
/// Sets an HTTP request header to intercept with multiple values.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "",
"$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json",
"id": "content-as-base64-string-bundle",
"comment": "An HTTP request bundle with content as a Base64 string.",
"version": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "",
"$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json",
"id": "content-as-html-string-bundle",
"comment": "An HTTP request bundle with content as a string.",
"version": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "",
"$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json",
"id": "content-as-json-array-bundle",
"comment": "An HTTP request bundle with content as a JSON array.",
"version": 1,
Expand All @@ -8,7 +8,9 @@
"comment": "An HTTP request that returns a JSON array.",
"uri": "https://api.github.com/orgs/justeat/repos",
"contentFormat": "json",
"contentJson": [ "httpclient-interception" ]
"contentJson": [
"httpclient-interception"
]
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "",
"$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json",
"id": "content-as-json-object-bundle",
"comment": "An HTTP request bundle with content as a JSON object.",
"items": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "",
"$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json",
"id": "custom-method-and-version-bundle",
"comment": "An HTTP request bundle for a non-default HTTP method and version.",
"items": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "",
"$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json",
"id": "test-http-request-bundle",
"comment": "An HTTP request bundle for testing purposes.",
"version": 1,
Expand All @@ -9,7 +9,9 @@
"comment": "A simple HTTP request that returns HTML.",
"uri": "https://www.just-eat.co.uk/",
"contentHeaders": {
"content-type": [ "text/html; charset=utf-8" ]
"content-type": [
"text/html; charset=utf-8"
]
},
"contentString": "<html><head><title>Just Eat</title></head></html>"
},
Expand All @@ -32,14 +34,26 @@
"version": "1.1",
"uri": "https://api.github.com/orgs/justeat",
"requestHeaders": {
"Accept": [ "application/vnd.github.v3+json" ],
"Authorization": [ "token my-token" ],
"User-Agent": [ "My-App/1.0.0" ]
"Accept": [
"application/vnd.github.v3+json"
],
"Authorization": [
"token my-token"
],
"User-Agent": [
"My-App/1.0.0"
]
},
"responseHeaders": {
"Access-Control-Allow-Origin": [ "*" ],
"Server": [ "GitHub.com" ],
"X-RateLimit-Limit": [ "60" ]
"Access-Control-Allow-Origin": [
"*"
],
"Server": [
"GitHub.com"
],
"X-RateLimit-Limit": [
"60"
]
},
"contentFormat": "json",
"contentJson": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
{
"$schema": "",
"$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json",
"id": "non-default-http-statuses-bundle",
"comment": "An HTTP request bundle for non-default HTTP status codes.",
"items": [
{
"uri": "https://www.just-eat.co.uk/1",
"status": "404",
"contentHeaders": {
"content-type": [ "text/html" ]
"content-type": [
"text/html"
]
},
"contentString": "<html><head><title>Just Eat</title></head></html>"
},
{
"uri": "https://www.just-eat.co.uk/2",
"status": "NotFound",
"contentHeaders": {
"content-type": [ "text/html" ]
"content-type": [
"text/html"
]
},
"contentString": "<html><head><title>Just Eat</title></head></html>"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "",
"$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json",
"id": "templated-base64-string-bundle",
"comment": "An HTTP request bundle that uses templating for a Base64-encoded string.",
"version": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "",
"$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json",
"id": "templated-json-bundle",
"comment": "An HTTP request bundle that uses templating for JSON.",
"version": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "",
"$schema": "https://raw.githubusercontent.com/justeat/httpclient-interception/master/src/HttpClientInterception/Bundles/http-request-bundle-schema.json",
"id": "templated-string-bundle",
"comment": "An HTTP request bundle that uses templating for a string.",
"version": 1,
Expand All @@ -8,13 +8,19 @@
"comment": "An HTTP request for a string that uses templating.",
"uri": "${Scheme}://www.just-eat.co.uk/",
"responseHeaders": {
"Server": [ "${ServerUrl}" ]
"Server": [
"${ServerUrl}"
]
},
"requestHeaders": {
"User-Agent": [ "${ApplicationName}/1.0.0" ]
"User-Agent": [
"${ApplicationName}/1.0.0"
]
},
"contentHeaders": {
"content-type": [ "${MediaType}" ]
"content-type": [
"${MediaType}"
]
},
"contentString": "<html><head><title>${CompanyName}</title></head></html>",
"templateValues": {
Expand Down

0 comments on commit 3894821

Please sign in to comment.