generated from admin/template
Backup
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokedexApi", "PokedexApi\PokedexApi.csproj", "{0AC1C38E-7B58-4271-9193-B74B674ECF6C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0AC1C38E-7B58-4271-9193-B74B674ECF6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0AC1C38E-7B58-4271-9193-B74B674ECF6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0AC1C38E-7B58-4271-9193-B74B674ECF6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0AC1C38E-7B58-4271-9193-B74B674ECF6C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.11"/>
|
||||
<PackageReference Include="Scalar.AspNetCore" Version="2.18.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
@PokedexApi_HostAddress = http://localhost:5116
|
||||
|
||||
GET {{PokedexApi_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
@@ -0,0 +1,46 @@
|
||||
using Scalar.AspNetCore;
|
||||
|
||||
// 1. Модели теперь можно объявить здесь, так как они находятся внутри пространства имен
|
||||
public record Pokemon(int Id, string Name, string Type, int Level);
|
||||
public record PokemonInput(string Name, string Type, int Level);
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
var pokemons = new List<Pokemon>
|
||||
{
|
||||
new(1, "Pikachu", "Electric", 12),
|
||||
new(2, "Charmander", "Fire", 8),
|
||||
new(3, "Squirtle", "Water", 10)
|
||||
};
|
||||
|
||||
// GET /pokemons
|
||||
app.MapGet("/pokemons/{id}", (int id) =>
|
||||
{
|
||||
var pokemon = pokemons.FirstOrDefault(p => p.Id == id);
|
||||
|
||||
return pokemon is null
|
||||
? Results.NotFound()
|
||||
: Results.Ok(pokemon);
|
||||
});
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
app.MapScalarApiReference(options =>
|
||||
{
|
||||
options.WithTitle("Pokedex API")
|
||||
.WithOpenApiRoutePattern("/openapi/v1.json");
|
||||
});
|
||||
}
|
||||
|
||||
app.Run();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5116",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "https://localhost:7103;http://localhost:5116",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user