Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,5 @@ GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml


.idea/.idea.Digipolis.Web/.idea/
24 changes: 14 additions & 10 deletions samples/Digipolis.Web.SampleApi/Configuration/Version2.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
using Swashbuckle.AspNetCore.Swagger;
using System;
using Microsoft.OpenApi.Models;

namespace Digipolis.Web.SampleApi.Configuration
{
/// <summary>
/// Contains all information for V2 of the API
/// </summary>
public class Version2 : Info
public class Version2 : OpenApiInfo
{
/// <summary>
/// Constructs OpenApiInfo object for version 2 of the API
/// </summary>
public Version2()
{
this.Version = Versions.V2;
this.Title = "API V2";
this.Description = "Description for V2 of the API";
this.Contact = new Contact { Email = "[email protected]", Name = "Digipolis", Url = "https://www.digipolis.be" };
this.TermsOfService = "https://www.digipolis.be/tos";
this.License = new License
Version = Versions.V2;
Title = "API V2";
Description = "Description for V2 of the API";
Contact = new OpenApiContact {Email = "[email protected]", Name = "Digipolis", Url = new Uri("https://www.digipolis.be")};
TermsOfService = new Uri("https://www.digipolis.be/tos");
License = new OpenApiLicense
{
Name = "My License",
Url = "https://www.digipolis.be/licensing"
Url = new Uri("https://www.digipolis.be/licensing")
};
}
}
}
}
32 changes: 14 additions & 18 deletions samples/Digipolis.Web.SampleApi/Controllers/ValuesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,43 +33,38 @@ public ValuesController(IValueLogic valueLogic, ILogger<ValuesController> logger
/// <remarks>
/// This endpoint demostrates the use of the old <see cref="PagedResult{T}"/> and it's resulting json.
/// </remarks>
/// <param name="queryOptions">Query options from uri</param>
/// <returns>An array of value objects</returns>
[HttpGet()]
[HttpGet]
[ProducesResponseType(typeof(PagedResult<ValueDto>), 200)]
[AllowAnonymous]
[Versions(Versions.V1, Versions.V2)]
Copy link
Author

@XeNz XeNz Dec 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

versioning is currently probably broken

[Produces("application/hal+json")]
[Versions(Versions.V1, Versions.V2)]
public IActionResult Get([FromQuery]CriteriaDto criteria)
{
int total;
var values = _valueLogic.GetAll(criteria, out total);
//var result = queryOptions.ToPagedResult(values, total, "kevin", new { test = 0 });
var result = criteria.ToPagedResult(values, total, "Get", "Values", new { test = 0 });
var values = _valueLogic.GetAll(criteria, out var total);
var result = criteria.ToPagedResult(values, total, ControllerContext.ActionDescriptor.ActionName, ControllerContext.ActionDescriptor.ControllerName);
return Ok(result);
}

/// <summary>
/// Get all values
/// </summary>
/// <remarks>
/// This endpoint demostrates the use of the new <see cref="PagedResult{T, EmbeddedT}"/> and it's resulting json.
/// </remarks>
/// <param name="queryOptions">Query options from uri</param>
/// <param name="criteria">Query options from uri</param>
/// <returns>An array of value objects</returns>
[HttpGet("new")]
[ProducesResponseType(typeof(PagedResult<ValueDto, EmbeddedValueDto>), 200)]
[AllowAnonymous]
[Versions(Versions.V1, Versions.V2)]
[Produces("application/hal+json")]
public IActionResult GetNew([FromQuery]CriteriaDto criteria)
{
int total;
var values = _valueLogic.GetAll(criteria, out total);
//var result = queryOptions.ToPagedResult(values, total, "kevin", new { test = 0 });
var values = _valueLogic.GetAll(criteria, out var total);
var result = criteria.ToPagedResult<ValueDto, EmbeddedValueDto>(values, total);
return Ok(result);
}

/// <summary>
/// Get a value by id
/// </summary>
Expand All @@ -79,13 +74,14 @@ public IActionResult GetNew([FromQuery]CriteriaDto criteria)
[ProducesResponseType(typeof(ValueDto), 200)]
[ProducesResponseType(typeof(ValueDto), 401)]
[AllowAnonymous]
[Versions(Versions.V1, Versions.V2)]
[Produces("application/json", "text/csv")]
public IActionResult Get(int id)
{
var value = _valueLogic.GetById(id);
return Ok(value);
}

/// <summary>
/// Add a new value
/// </summary>
Expand All @@ -101,7 +97,7 @@ public IActionResult Post([FromBody, Required] ValueDto value)
value = _valueLogic.Add(value);
return CreatedAtAction("Get", new { id = value.Id }, value);
}

/// <summary>
/// Update an existing value object
/// </summary>
Expand All @@ -117,7 +113,7 @@ public IActionResult Put(int id, [FromBody, Required] ValueDto value)
value = _valueLogic.Update(id, value);
return Ok(value);
}

/// <summary>
/// Delete a value by it's Id
/// </summary>
Expand All @@ -130,9 +126,9 @@ public IActionResult Delete(int id)
_valueLogic.Delete(id);
return NoContent();
}

/// <summary>
/// Thorws an exception
/// Throws an exception
/// </summary>
/// <returns></returns>
[HttpGet("exception")]
Expand Down
81 changes: 45 additions & 36 deletions samples/Digipolis.Web.SampleApi/Digipolis.Web.SampleApi.csproj
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>Digipolis.Web.SampleApi</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Digipolis.Web.SampleApi</PackageId>
<RuntimeFrameworkVersion>2.1.6</RuntimeFrameworkVersion>
</PropertyGroup>

<ItemGroup>
<None Update="Views;Areas\**\Views">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Digipolis.Web\Digipolis.Web.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="4.0.1" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>Digipolis.Web.SampleApi</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Digipolis.Web.SampleApi</PackageId>
</PropertyGroup>

<ItemGroup>
<None Update="Views;Areas\**\Views">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Digipolis.Web\Digipolis.Web.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="AutoMapper" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.0.0-rc5" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.0.0-rc5" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="5.0.0-rc5" />
</ItemGroup>


<PropertyGroup>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(MSBuildThisFileName).xml</DocumentationFile>
</PropertyGroup>


<ItemGroup>
<Folder Include="Swagger" />
</ItemGroup>

</Project>
5 changes: 4 additions & 1 deletion samples/Digipolis.Web.SampleApi/Models/ChildDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
{
public class ChildDto
{
/// <summary>
/// The Id of the child
/// </summary>
public int Id { get; set; }
}
}
}
25 changes: 21 additions & 4 deletions samples/Digipolis.Web.SampleApi/Models/CriteriaDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,34 @@ namespace Digipolis.Web.SampleApi.Models
{
public class CriteriaDto : PageSortOptions
{
/// <summary>
/// Test bool
/// </summary>
public bool? TestBool { get; set; }


/// <summary>
/// Test String array
/// </summary>
public string[] StringArray { get; set; }

/// <summary>
/// Test String List
/// </summary>
public List<string> StringList { get; set; }

/// <summary>
/// Test Int Array
/// </summary>
public int[] IntArray { get; set; }

/// <summary>
/// Test Int List
/// </summary>
public List<int> IntList { get; set; }

/// <summary>
/// Test Complex array
/// </summary>
public ChildDto[] ComplexArray { get; set; }

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Digipolis.Web.SampleApi": {
"commandName": "Project",
"launchBrowser": true,
Expand Down
Loading