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

Merge master into openapi #1665

Merged
merged 3 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"requestBody": {
"description": "An array of mutation operations. For syntax, see the [Atomic Operations documentation](https://jsonapi.org/ext/atomic/).",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"allOf": [
{
Expand All @@ -36,7 +36,7 @@
"200": {
"description": "All operations were successfully applied, which resulted in additional changes.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/operationsResponseDocument"
}
Expand All @@ -49,7 +49,7 @@
"400": {
"description": "The request body is missing or malformed.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -59,7 +59,7 @@
"403": {
"description": "An operation is not accessible or a client-generated ID is used.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -69,7 +69,7 @@
"404": {
"description": "A resource or a related resource does not exist.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -79,7 +79,7 @@
"409": {
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -89,7 +89,7 @@
"422": {
"description": "Validation of the request body failed.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public RequestInformation ToPostRequestInformation(global::OpenApiKiotaClientExa
_ = body ?? throw new ArgumentNullException(nameof(body));
var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters);
requestInfo.Configure(requestConfiguration);
requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=atomic-operations");
requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=atomic-operations", body);
requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=atomic");
requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=atomic", body);
return requestInfo;
}
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/JsonApiDotNetCore/Middleware/HeaderConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public static class HeaderConstants
public const string AtomicOperationsMediaType = $"{MediaType}; ext=\"https://jsonapi.org/ext/atomic\"";

[Obsolete($"Use {nameof(JsonApiMediaType)}.{nameof(JsonApiMediaType.RelaxedAtomicOperations)}.ToString() instead.")]
public const string RelaxedAtomicOperationsMediaType = $"{MediaType}; ext=atomic-operations";
public const string RelaxedAtomicOperationsMediaType = $"{MediaType}; ext=atomic";
}
2 changes: 1 addition & 1 deletion src/JsonApiDotNetCore/Middleware/JsonApiMediaType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed class JsonApiMediaType : IEquatable<JsonApiMediaType>
public static readonly JsonApiMediaType AtomicOperations = new([JsonApiMediaTypeExtension.AtomicOperations]);

/// <summary>
/// Gets the JSON:API media type with the "atomic-operations" extension.
/// Gets the JSON:API media type with the "atomic" extension.
/// </summary>
public static readonly JsonApiMediaType RelaxedAtomicOperations = new([JsonApiMediaTypeExtension.RelaxedAtomicOperations]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace JsonApiDotNetCore.Middleware;
public sealed class JsonApiMediaTypeExtension : IEquatable<JsonApiMediaTypeExtension>
{
public static readonly JsonApiMediaTypeExtension AtomicOperations = new("https://jsonapi.org/ext/atomic");
public static readonly JsonApiMediaTypeExtension RelaxedAtomicOperations = new("atomic-operations");
public static readonly JsonApiMediaTypeExtension RelaxedAtomicOperations = new("atomic");

public string UnescapedValue { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public async Task Prefers_JsonApi_with_AtomicOperations_extension_in_Accept_head
headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse($"{JsonApiMediaType.Default}; profile=some"));
headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse(JsonApiMediaType.Default.ToString()));
headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse($"{JsonApiMediaType.Default}; unknown=unexpected"));
headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse($"{JsonApiMediaType.Default};EXT=atomic-operations; q=0.8"));
headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse($"{JsonApiMediaType.Default};EXT=atomic; q=0.8"));
headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse($"{JsonApiMediaType.Default};EXT=\"https://jsonapi.org/ext/atomic\"; q=0.2"));
};

Expand Down Expand Up @@ -168,7 +168,7 @@ public async Task Prefers_JsonApi_with_relaxed_AtomicOperations_extension_in_Acc
headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse(JsonApiMediaType.Default.ToString()));
headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse($"{JsonApiMediaType.Default}; unknown=unexpected"));
headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse($"{JsonApiMediaType.Default};EXT=\"https://jsonapi.org/ext/atomic\"; q=0.8"));
headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse($"{JsonApiMediaType.Default};EXT=atomic-operations; q=0.2"));
headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse($"{JsonApiMediaType.Default};EXT=atomic; q=0.2"));
};

// Act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public RequestInformation ToPostRequestInformation(global::OpenApiKiotaEndToEndT
_ = body ?? throw new ArgumentNullException(nameof(body));
var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters);
requestInfo.Configure(requestConfiguration);
requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=atomic-operations");
requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=atomic-operations", body);
requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=atomic");
requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=atomic", body);
return requestInfo;
}
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2996,7 +2996,7 @@
"requestBody": {
"description": "An array of mutation operations. For syntax, see the [Atomic Operations documentation](https://jsonapi.org/ext/atomic/).",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"allOf": [
{
Expand All @@ -3012,7 +3012,7 @@
"200": {
"description": "All operations were successfully applied, which resulted in additional changes.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/operationsResponseDocument"
}
Expand All @@ -3025,7 +3025,7 @@
"400": {
"description": "The request body is missing or malformed.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -3035,7 +3035,7 @@
"403": {
"description": "An operation is not accessible or a client-generated ID is used.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -3045,7 +3045,7 @@
"404": {
"description": "A resource or a related resource does not exist.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -3055,7 +3055,7 @@
"409": {
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -3065,7 +3065,7 @@
"422": {
"description": "Validation of the request body failed.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand Down
14 changes: 7 additions & 7 deletions test/OpenApiTests/AtomicOperations/OperationsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task Operations_endpoint_is_exposed()
"requestBody": {
"description": "An array of mutation operations. For syntax, see the [Atomic Operations documentation](https://jsonapi.org/ext/atomic/).",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"allOf": [
{
Expand All @@ -57,7 +57,7 @@ public async Task Operations_endpoint_is_exposed()
"200": {
"description": "All operations were successfully applied, which resulted in additional changes.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/operationsResponseDocument"
}
Expand All @@ -70,7 +70,7 @@ public async Task Operations_endpoint_is_exposed()
"400": {
"description": "The request body is missing or malformed.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -80,7 +80,7 @@ public async Task Operations_endpoint_is_exposed()
"403": {
"description": "An operation is not accessible or a client-generated ID is used.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -90,7 +90,7 @@ public async Task Operations_endpoint_is_exposed()
"404": {
"description": "A resource or a related resource does not exist.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -100,7 +100,7 @@ public async Task Operations_endpoint_is_exposed()
"409": {
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -110,7 +110,7 @@ public async Task Operations_endpoint_is_exposed()
"422": {
"description": "Validation of the request body failed.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand Down
2 changes: 1 addition & 1 deletion test/OpenApiTests/Documentation/ErrorResponseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace OpenApiTests.Documentation;
public sealed class ErrorResponseTests : IClassFixture<OpenApiTestContext<DocumentationStartup<DocumentationDbContext>, DocumentationDbContext>>
{
private const string EscapedJsonApiMediaType = "['application/vnd.api+json']";
private const string EscapedOperationsMediaType = "['application/vnd.api+json; ext=atomic-operations']";
private const string EscapedOperationsMediaType = "['application/vnd.api+json; ext=atomic']";

private readonly OpenApiTestContext<DocumentationStartup<DocumentationDbContext>, DocumentationDbContext> _testContext;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,10 @@ public async Task Casing_convention_is_applied_to_PostOperations_endpoint()
operationElement.Should().Be("postOperations");
});

getElement.Should().ContainPath("requestBody.content['application/vnd.api+json; ext=atomic-operations'].schema.allOf[0].$ref")
getElement.Should().ContainPath("requestBody.content['application/vnd.api+json; ext=atomic'].schema.allOf[0].$ref")
.ShouldBeSchemaReferenceId("operationsRequestDocument");

getElement.Should().ContainPath("responses.200.content['application/vnd.api+json; ext=atomic-operations'].schema.$ref")
getElement.Should().ContainPath("responses.200.content['application/vnd.api+json; ext=atomic'].schema.$ref")
.ShouldBeSchemaReferenceId("operationsResponseDocument");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"requestBody": {
"description": "An array of mutation operations. For syntax, see the [Atomic Operations documentation](https://jsonapi.org/ext/atomic/).",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"allOf": [
{
Expand All @@ -36,7 +36,7 @@
"200": {
"description": "All operations were successfully applied, which resulted in additional changes.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/operationsResponseDocument"
}
Expand All @@ -49,7 +49,7 @@
"400": {
"description": "The request body is missing or malformed.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -59,7 +59,7 @@
"403": {
"description": "An operation is not accessible or a client-generated ID is used.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -69,7 +69,7 @@
"404": {
"description": "A resource or a related resource does not exist.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -79,7 +79,7 @@
"409": {
"description": "The request body contains conflicting information or another resource with the same ID already exists.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand All @@ -89,7 +89,7 @@
"422": {
"description": "Validation of the request body failed.",
"content": {
"application/vnd.api+json; ext=atomic-operations": {
"application/vnd.api+json; ext=atomic": {
"schema": {
"$ref": "#/components/schemas/errorResponseDocument"
}
Expand Down
Loading
Loading