Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -330,6 +330,35 @@
}
}
},
"/WithOpenApi/IFromBody": {
"post": {
"tags": [
"WithOpenApi"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OrganizationCustomExchangeRatesDto"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/XmlComments/Car/{id}": {
"get": {
"tags": [
Expand Down Expand Up @@ -445,6 +474,29 @@
},
"additionalProperties": false
},
"CurrenciesRate": {
"required": [
"currencyFrom",
"currencyTo",
"rate"
],
"type": "object",
"properties": {
"currencyFrom": {
"type": "string",
"nullable": true
},
"currencyTo": {
"type": "string",
"nullable": true
},
"rate": {
"type": "number",
"format": "double"
}
},
"additionalProperties": false
},
"DateTimeKind": {
"enum": [
0,
Expand All @@ -465,6 +517,22 @@
"additionalProperties": false,
"description": "Description for Schema"
},
"OrganizationCustomExchangeRatesDto": {
"required": [
"currenciesRates"
],
"type": "object",
"properties": {
"currenciesRates": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CurrenciesRate"
},
"nullable": true
}
},
"additionalProperties": false
},
"Person": {
"type": "object",
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,35 @@
}
}
},
"/WithOpenApi/IFromBody": {
"post": {
"tags": [
"WithOpenApi"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OrganizationCustomExchangeRatesDto"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/XmlComments/Car/{id}": {
"get": {
"tags": [
Expand Down Expand Up @@ -445,6 +474,29 @@
},
"additionalProperties": false
},
"CurrenciesRate": {
"required": [
"currencyFrom",
"currencyTo",
"rate"
],
"type": "object",
"properties": {
"currencyFrom": {
"type": "string",
"nullable": true
},
"currencyTo": {
"type": "string",
"nullable": true
},
"rate": {
"type": "number",
"format": "double"
}
},
"additionalProperties": false
},
"DateTimeKind": {
"enum": [
0,
Expand All @@ -465,6 +517,22 @@
"additionalProperties": false,
"description": "Description for Schema"
},
"OrganizationCustomExchangeRatesDto": {
"required": [
"currenciesRates"
],
"type": "object",
"properties": {
"currenciesRates": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CurrenciesRate"
},
"nullable": true
}
},
"additionalProperties": false
},
"Person": {
"type": "object",
"properties": {
Expand Down
10 changes: 9 additions & 1 deletion test/WebSites/WebApi/EndPoints/OpenApiEndpoints.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Mvc;

namespace WebApi.EndPoints
{
Expand Down Expand Up @@ -51,6 +52,11 @@ public static IEndpointRouteBuilder MapWithOpenApiEndpoints(this IEndpointRouteB
return $"{collection.Count} {string.Join(',', collection.Select(f => f.FileName))}";
}).WithOpenApi();

group.MapPost("/IFromBody", (OrganizationCustomExchangeRatesDto dto) =>
{
return $"{dto}";
}).WithOpenApi();

return app;
}
}
Expand All @@ -61,4 +67,6 @@ record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
record class Person(string FirstName, string LastName);

record class Address(string Street, string City, string State, string ZipCode);
sealed record OrganizationCustomExchangeRatesDto([property: JsonRequired] CurrenciesRate[] CurrenciesRates);
sealed record CurrenciesRate([property: JsonRequired] string currencyFrom, [property: JsonRequired] string currencyTo, [property: JsonRequired] double rate);
}