Skip to content

Commit

Permalink
Consum API
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanjofigue97 committed Apr 26, 2024
1 parent e524065 commit 04903e3
Show file tree
Hide file tree
Showing 69 changed files with 3,775 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<None Include="OpenAPIs\swagger.json" />
</ItemGroup>

<ItemGroup>
<None Include="OpenAPIs\swagger1.json" ClassName="TodoApi" />
</ItemGroup>

<ItemGroup>
<OpenApiReference Include="OpenAPIs\swagger2.json" CodeGenerator="NSwagCSharp" Namespace="BlazoApiGenereatedClient.Services" ClassName="TodoApi">
<SourceUri>https://localhost:7000/swagger/v1/swagger.json</SourceUri>
</OpenApiReference>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.ApiDescription.Client" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NSwag.ApiDescription.Client" Version="13.18.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace BlazoApiGenereatedClient.Data
{
public class WeatherForecast
{
public DateOnly Date { get; set; }

public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string? Summary { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace BlazoApiGenereatedClient.Data
{
public class WeatherForecastService
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

public Task<WeatherForecast[]> GetForecastAsync(DateOnly startDate)
{
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = startDate.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
}).ToArray());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,310 @@
{
"openapi": "3.0.1",
"info": {
"title": "TodoApi",
"version": "1.0"
},
"paths": {
"/api/Authentication/token": {
"post": {
"tags": [
"Authentication"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AuthenticationData"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/AuthenticationData"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/AuthenticationData"
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
},
"application/json": {
"schema": {
"type": "string"
}
},
"text/json": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/api/Todos": {
"get": {
"tags": [
"Todos"
],
"operationId": "GetAllTodos",
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/TodoModel"
}
}
},
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/TodoModel"
}
}
},
"text/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/TodoModel"
}
}
}
}
}
}
},
"post": {
"tags": [
"Todos"
],
"operationId": "CreateTodos",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "string"
}
},
"text/json": {
"schema": {
"type": "string"
}
},
"application/*+json": {
"schema": {
"type": "string"
}
}
}
},
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/TodoModel"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/TodoModel"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/TodoModel"
}
}
}
}
}
}
},
"/api/Todos/{todoId}": {
"get": {
"tags": [
"Todos"
],
"operationId": "GetOneTodos",
"parameters": [
{
"name": "todoId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/TodoModel"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/TodoModel"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/TodoModel"
}
}
}
}
}
},
"put": {
"tags": [
"Todos"
],
"operationId": "UpdateTodos",
"parameters": [
{
"name": "todoId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "string"
}
},
"text/json": {
"schema": {
"type": "string"
}
},
"application/*+json": {
"schema": {
"type": "string"
}
}
}
},
"responses": {
"200": {
"description": "Success"
}
}
},
"delete": {
"tags": [
"Todos"
],
"operationId": "DeleteTodos",
"parameters": [
{
"name": "todoId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
},
"/api/Todos/{todoId}/Complete": {
"put": {
"tags": [
"Todos"
],
"operationId": "CompleteTodos",
"parameters": [
{
"name": "todoId",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "Success"
}
}
}
}
},
"components": {
"schemas": {
"AuthenticationData": {
"type": "object",
"properties": {
"userName": {
"type": "string",
"nullable": true
},
"password": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
},
"TodoModel": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"task": {
"type": "string",
"nullable": true
},
"assignedTo": {
"type": "integer",
"format": "int32"
},
"isComplete": {
"type": "boolean"
}
},
"additionalProperties": false
}
}
}
}
Loading

0 comments on commit 04903e3

Please sign in to comment.