Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
KrothuTheCoder committed Mar 12, 2024
2 parents def214d + 592cba9 commit 83f7525
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 127 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "C#: <project-name> Debug",
"type": "dotnet",
"request": "launch",
"projectPath": "${workspaceFolder}/DoSomethingService/DoSomethingService.csproj"
}

]
}
59 changes: 59 additions & 0 deletions DoSomethingService/Controllers/v1/SomethingController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Mvc;

namespace DoSomethingService.Controllers.v1;

/// <summary>
/// This is an api to return some data in a made up senario
/// </summary>
[Route("api/v1/[controller]")]
[ApiController]
[ApiVersion("1.0")]
public class SomethingController : ControllerBase
{
private readonly ILogger<SomethingController> _logger;

/// <summary>
/// Setting up the code so it can do things
/// </summary>
/// <param name="logger">The logger so we know if things have been done</param>
public SomethingController(ILogger<SomethingController> logger)
{
_logger = logger;
}

/// <summary>
/// If you need to do something then it will
/// </summary>
/// <returns>What happened</returns>
[HttpGet("DoSomething")]
[ApiExplorerSettings(GroupName ="v1")]
public string Get()
{
return $"You wanted me to do something, there I did something";
}

/// <summary>
/// If you need to do something then, just tell it
/// what you want to do
/// </summary>
/// <param name="whatToDo">The thing you want it to do</param>
/// <returns>What happened</returns>
[HttpGet("WhatSomethingToDo")]
[ApiExplorerSettings(GroupName ="v1")]
public string Get(string whatToDo)
{
return $"You wanted me to {whatToDo}, there I did something";
}

/// <summary>
/// If you want to post something for it to do
/// </summary>
/// <param name="whatToDo">The thing you want it to do</param>
/// <returns>What happened</returns>
[HttpPost("PostSomething")]
[ApiExplorerSettings(GroupName ="v1")]
public string Post(string whatToDo)
{
return $"This was passed to me {whatToDo}, there I did something";
}
}
44 changes: 0 additions & 44 deletions DoSomethingService/Controllers/v1/SomethingV1Controller.cs

This file was deleted.

73 changes: 73 additions & 0 deletions DoSomethingService/Controllers/v2/SomethingController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using Microsoft.AspNetCore.Mvc;

namespace DoSomethingService.Controllers.v2;

/// <summary>
/// This is an api to return some data in a made up senario
/// </summary>
[Route("api/v2/[controller]")]
[ApiController]
[ApiVersion("2.0")]
public class SomethingController : ControllerBase
{
private readonly ILogger<SomethingController> _logger;

/// <summary>
/// Setting up the code so it can do things
/// </summary>
/// <param name="logger">The logger so we know if things have been done</param>
public SomethingController(ILogger<SomethingController> logger)
{
_logger = logger;
}

/// <summary>
/// If you need to do something then it will
/// </summary>
/// <returns>What happened</returns>
[HttpGet("DoSomething")]
[ApiExplorerSettings(GroupName ="v2")]
public string Get()
{
return $"You wanted me to do something, there I did something";
}

/// <summary>
/// If you need to do something then, just tell it
/// what you want to do
/// </summary>
/// <param name="whatToDo">The thing you want it to do</param>
/// <returns>What happened</returns>
[HttpGet("WhatSomethingToDo")]
[ApiExplorerSettings(GroupName ="v2")]
public string Get(int whatToDo)
{
return $"You wanted me to {whatToDo}, there I did something";
}

/// <summary>
/// If you want to post something for it to do
/// </summary>
/// <param name="whatToDo">The thing you want it to do</param>
/// <returns>What happened</returns>
[HttpPost("PostSomething")]
[ApiExplorerSettings(GroupName ="v2")]
public string Post(string whatToDo)
{
return $"This was passed to me {whatToDo}, there I did something";
}

/// <summary>
/// If you need to do something then, just tell it
/// what you want to do
/// </summary>
/// <param name="whatToDo">The thing you want it to do</param>
/// <returns>What happened</returns>
[HttpGet("WhatAnotherSomethingToDo")]
[ApiExplorerSettings(GroupName ="v2")]
public string GetAnother(int whatToDo)
{
return $"You wanted me to {whatToDo}, there I did something";
}

}
44 changes: 0 additions & 44 deletions DoSomethingService/Controllers/v2/SomethingV2Controller.cs

This file was deleted.

10 changes: 9 additions & 1 deletion DoSomethingService/DoSomethingService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.1" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>

</Project>
Loading

0 comments on commit 83f7525

Please sign in to comment.