diff --git a/src/CommunityToolkit.Datasync.Server.Swashbuckle/DatasyncDocumentFilter.cs b/src/CommunityToolkit.Datasync.Server.Swashbuckle/DatasyncDocumentFilter.cs
index f24193de..0d4f9561 100644
--- a/src/CommunityToolkit.Datasync.Server.Swashbuckle/DatasyncDocumentFilter.cs
+++ b/src/CommunityToolkit.Datasync.Server.Swashbuckle/DatasyncDocumentFilter.cs
@@ -112,6 +112,7 @@ internal void ProcessController(Type entityType, string routePath, OpenApiDocume
case OpType.Create:
// Request Edits
operation.Value.AddConditionalHeader(true);
+ operation.Value.AddRequestWithContent(context.SchemaRepository.Schemas[entityType.Name]);
// Response Edits
operation.Value.AddResponseWithContent("201", "Created", context.SchemaRepository.Schemas[entityType.Name]);
@@ -152,6 +153,7 @@ internal void ProcessController(Type entityType, string routePath, OpenApiDocume
case OpType.Replace:
// Request Edits
operation.Value.AddConditionalHeader();
+ operation.Value.AddRequestWithContent(context.SchemaRepository.Schemas[entityType.Name]);
// Response Edits
operation.Value.AddResponseWithContent("200", "OK", context.SchemaRepository.Schemas[entityType.Name]);
diff --git a/src/CommunityToolkit.Datasync.Server.Swashbuckle/DatasyncOperationExtensions.cs b/src/CommunityToolkit.Datasync.Server.Swashbuckle/DatasyncOperationExtensions.cs
index e6dcbc4b..caed0448 100644
--- a/src/CommunityToolkit.Datasync.Server.Swashbuckle/DatasyncOperationExtensions.cs
+++ b/src/CommunityToolkit.Datasync.Server.Swashbuckle/DatasyncOperationExtensions.cs
@@ -95,6 +95,24 @@ internal static void AddResponseWithContent(this OpenApiOperation operation, str
});
operation.Responses[statusCode] = response;
}
+ ///
+ /// Adds the content type and schema to the request body.
+ ///
+ /// The to modify.
+ /// The schema of the entity in the request.
+ internal static void AddRequestWithContent(this OpenApiOperation operation, OpenApiSchema schema)
+ {
+ operation.RequestBody = new OpenApiRequestBody
+ {
+ Content = new Dictionary
+ {
+ [JsonMediaType] = new OpenApiMediaType()
+ {
+ Schema = schema
+ }
+ }
+ };
+ }
///
/// Adds or replaces the 409/412 Conflict/Precondition Failed response.
diff --git a/tests/CommunityToolkit.Datasync.Server.Swashbuckle.Test/swagger.json b/tests/CommunityToolkit.Datasync.Server.Swashbuckle.Test/swagger.json
index 59c886ba..7623daf6 100644
--- a/tests/CommunityToolkit.Datasync.Server.Swashbuckle.Test/swagger.json
+++ b/tests/CommunityToolkit.Datasync.Server.Swashbuckle.Test/swagger.json
@@ -159,6 +159,15 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/KitchenSink"
+ }
+ }
+ }
+ },
"responses": {
"201": {
"description": "Created",
@@ -448,6 +457,15 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/KitchenSink"
+ }
+ }
+ }
+ },
"responses": {
"200": {
"description": "OK",
@@ -530,6 +548,15 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/TodoItem"
+ }
+ }
+ }
+ },
"responses": {
"201": {
"description": "Created",
@@ -819,6 +846,15 @@
}
}
],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/TodoItem"
+ }
+ }
+ }
+ },
"responses": {
"200": {
"description": "OK",