Skip to content

Commit

Permalink
Add VerificationTests
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier García de la Noceda Argüelles committed Jul 18, 2024
1 parent 55d8841 commit 85d39c1
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 1 deletion.
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);
}

0 comments on commit 85d39c1

Please sign in to comment.