Skip to content
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 @@ -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]);
Expand Down Expand Up @@ -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]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@ internal static void AddResponseWithContent(this OpenApiOperation operation, str
});
operation.Responses[statusCode] = response;
}
/// <summary>
/// Adds the content type and schema to the request body.
/// </summary>
/// <param name="operation">The <see cref="OpenApiOperation"/> to modify.</param>
/// <param name="schema">The schema of the entity in the request.</param>
internal static void AddRequestWithContent(this OpenApiOperation operation, OpenApiSchema schema)
{
operation.RequestBody = new OpenApiRequestBody
{
Content = new Dictionary<string, OpenApiMediaType>
{
[JsonMediaType] = new OpenApiMediaType()
{
Schema = schema
}
}
};
}

/// <summary>
/// Adds or replaces the 409/412 Conflict/Precondition Failed response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/KitchenSink"
}
}
}
},
"responses": {
"201": {
"description": "Created",
Expand Down Expand Up @@ -448,6 +457,15 @@
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/KitchenSink"
}
}
}
},
"responses": {
"200": {
"description": "OK",
Expand Down Expand Up @@ -530,6 +548,15 @@
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TodoItem"
}
}
}
},
"responses": {
"201": {
"description": "Created",
Expand Down Expand Up @@ -819,6 +846,15 @@
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TodoItem"
}
}
}
},
"responses": {
"200": {
"description": "OK",
Expand Down
Loading