Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ResearchFi.CodeList;

namespace ResearchFi.ResearchDataset;
namespace ResearchFi.ResearchDataset.Common;

/// <summary>
/// Contributor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ResearchFi.ResearchDataset;
namespace ResearchFi.ResearchDataset.Common;

/// <summary>
/// Dataset reference
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ResearchFi.ResearchDataset;
namespace ResearchFi.ResearchDataset.Common;

/// <summary>
/// Organization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ResearchFi.ResearchDataset;
namespace ResearchFi.ResearchDataset.Common;

/// <summary>
/// Person
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ResearchFi.ResearchDataset;
namespace ResearchFi.ResearchDataset.Common;

/// <summary>
/// Data catalog
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ResearchFi.ResearchDataset;
namespace ResearchFi.ResearchDataset.Common;

/// <summary>
/// Version reference
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using ResearchFi.CodeList;
using ResearchFi.ResearchDataset.Common;
using Version = ResearchFi.ResearchDataset.Common.Version;

namespace ResearchFi.ResearchDataset;
namespace ResearchFi.ResearchDataset.V1;

/// <summary>
/// Research data
Expand Down
41 changes: 41 additions & 0 deletions aspnetcore/src/ApiModels/V2/ResearchDataset/ResearchDataset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using ResearchFi.CodeList;
using ResearchFi.ResearchDataset.Common;
using Version = ResearchFi.ResearchDataset.Common.Version;

namespace ResearchFi.ResearchDataset.V2;

/// <summary>
/// Research data
/// </summary>
public class ResearchDataset
{
/// <summary>
/// Local identifier of the dataset
/// </summary>
public string? Id { get; set; }

/// <summary>
/// Name of the research data in Finnish
/// </summary>
public string? NameFi { get; set; }

/// <summary>
/// Name of the research data in Swedish
/// </summary>
public string? NameSv { get; set; }

/// <summary>
/// Name of the research data in English
/// </summary>
public string? NameEn { get; set; }

/// <summary>
/// Is this dataset the latest version
/// </summary>
public bool IsLatestVersion { get; set; }

/// <summary>
/// Researchfi portal URL
/// </summary>
public ResearchfiUrl? ResearchfiUrl { get; set; }
}
2 changes: 1 addition & 1 deletion aspnetcore/src/Exporter/Exporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using CSC.PublicApi.Service.Models.Publication;
using FundingCallApiModel = ResearchFi.FundingCall.FundingCall;
using FundingDecisionApiModel = ResearchFi.FundingDecision.FundingDecision;
using ResearchDatasetApiModel = ResearchFi.ResearchDataset.ResearchDataset;
using ResearchDatasetApiModel = ResearchFi.ResearchDataset.V1.ResearchDataset;
using PublicationApiModel = ResearchFi.Publication.Publication;
using System.Text.Json;

Expand Down
1 change: 1 addition & 0 deletions aspnetcore/src/Interface/ApiConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public static class ApiConstants
{
public const string ApiVersion1 = "1.0";
public const string ApiVersion2 = "2.0";
public const string ContentTypeJson = "application/json";
public const string LogResourceType_PropertyName = "ResourceType";
public const string LogResourceType_FundingCall = "funding_call";
Expand Down
19 changes: 14 additions & 5 deletions aspnetcore/src/Interface/Configuration/SwaggerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.OpenApi.Models;

namespace CSC.PublicApi.Interface.Configuration;
Expand All @@ -23,9 +24,17 @@ public static void AddSwaggerAndApiVersioning(this IServiceCollection services)
services.AddEndpointsApiExplorer();
services.AddSwaggerGen(options =>
{
// Needed because our models have non-unique names in different namespaces,
// causing error "SchemaId already used for different type".
options.CustomSchemaIds(type => type.FullName);
/*
* Modify generated schema IDs.
* Remove version number, which are used in namespace to separate API versions, from the schema ID.
* Example: ResearchFi.VirtaJtp.V1.DuplikaatitAPI -> ResearchFi.VirtaJtp.DuplikaatitAPI
*/
options.CustomSchemaIds(t =>
{
var full = t.FullName ?? t.Name;
full = Regex.Replace(full, @"(\.|^)V\d+(_\d+)?\.", "$1"); // removes ".V1." or ".V1_1." etc.
return full;
});
});
services.ConfigureOptions<SwaggerConfiguration>();
}
Expand Down Expand Up @@ -73,10 +82,10 @@ public static void UseSwaggerAndSwaggerUI(this WebApplication app)
});
app.UseSwaggerUI(options =>
{
options.ConfigObject.AdditionalItems.Add("syntaxHighlight", false); // disable to improve performance with large responses
foreach (var description in app.Services.GetRequiredService<IApiVersionDescriptionProvider>().ApiVersionDescriptions)
{
options.SwaggerEndpoint($"{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant());
options.ConfigObject.AdditionalItems.Add("syntaxHighlight", false); // disable to improve performance with large responses
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
namespace CSC.PublicApi.Interface.Controllers;

[ApiController]
[ApiVersion(ApiConstants.ApiVersion1)]
[ApiVersion(ApiVersion)]
[Route("v{version:apiVersion}/funders")]
public class FunderController : ControllerBase
{
private const string ApiVersion = ApiConstants.ApiVersion1;
private readonly ImportDbContext _importDbContext;
private readonly ILogger<FunderController> _logger;
private readonly IDiagnosticContext _diagnosticContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using CSC.PublicApi.Interface.Services;
/*
* API version 1.0
*/
using CSC.PublicApi.Interface.Services.V1;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ResearchFi.FundingCall;
Expand All @@ -8,10 +11,11 @@
namespace CSC.PublicApi.Interface.Controllers;

[ApiController]
[ApiVersion(ApiConstants.ApiVersion1)]
[ApiVersion(ApiVersion)]
[Route("v{version:apiVersion}/funding-calls")]
public class FundingCallController : ControllerBase
{
private const string ApiVersion = ApiConstants.ApiVersion1;
private readonly ILogger<FundingCallController> _logger;
private readonly IFundingCallService _service;
private readonly IDiagnosticContext _diagnosticContext;
Expand All @@ -36,7 +40,7 @@ public FundingCallController(
/// <response code="401">Unauthorized.</response>
/// <response code="403">Forbidden.</response>
[HttpGet(Name = "GetFundingCall")]
[MapToApiVersion(ApiConstants.ApiVersion1)]
[MapToApiVersion(ApiVersion)]
[Authorize(Policy = ApiPolicies.FundingCall.Read)]
[Produces(ApiConstants.ContentTypeJson)]
[Consumes(ApiConstants.ContentTypeJson)]
Expand All @@ -58,7 +62,7 @@ public async Task<IEnumerable<FundingCall>> Get([FromQuery] GetFundingCallQueryP
/// <param name="fundingCall"></param>
/// <returns></returns>
[HttpPost(Name = "PostFundingCall")]
[MapToApiVersion(ApiConstants.ApiVersion1)]
[MapToApiVersion(ApiVersion)]
[Authorize(Policy = ApiPolicies.FundingCall.Write)]
[ApiExplorerSettings(IgnoreApi = true)]
public async Task Post(FundingCall fundingCall)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using CSC.PublicApi.Interface.Services;
/*
* API version 1.0
*/
using CSC.PublicApi.Interface.Services.V1;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ResearchFi.FundingCall;
Expand All @@ -8,10 +11,11 @@
namespace CSC.PublicApi.Interface.Controllers;

[ApiController]
[ApiVersion(ApiConstants.ApiVersion1)]
[ApiVersion(ApiVersion)]
[Route("v{version:apiVersion}/funding-calls-export")]
public class FundingCallExportController : ControllerBase
{
private const string ApiVersion = ApiConstants.ApiVersion1;
private readonly ILogger<FundingCallExportController> _logger;
private readonly IFundingCallService _service;
private readonly IDiagnosticContext _diagnosticContext;
Expand All @@ -36,7 +40,7 @@ public FundingCallExportController(
/// <response code="401">Unauthorized.</response>
/// <response code="403">Forbidden.</response>
[HttpGet(Name = "GetFundingCallExport")]
[MapToApiVersion(ApiConstants.ApiVersion1)]
[MapToApiVersion(ApiVersion)]
[Authorize(Policy = ApiPolicies.FundingCall.Read)]
[Produces(ApiConstants.ContentTypeJson)]
[Consumes(ApiConstants.ContentTypeJson)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using CSC.PublicApi.Interface.Services;
/*
* API version 1.0
*/
using CSC.PublicApi.Interface.Services.V1;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ResearchFi.FundingDecision;
Expand All @@ -13,7 +16,7 @@ namespace CSC.PublicApi.Interface.Controllers;

public class FundingDecisionController : ControllerBase
{
private const string ApiVersion = "1.0";
private const string ApiVersion = ApiConstants.ApiVersion1;
private readonly ILogger<FundingDecisionController> _logger;
private readonly IFundingDecisionService _service;
private readonly IDiagnosticContext _diagnosticContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using CSC.PublicApi.Interface.Services;
/*
* API version 1.0
*/
using CSC.PublicApi.Interface.Services.V1;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ResearchFi.FundingDecision;
Expand All @@ -13,7 +16,7 @@ namespace CSC.PublicApi.Interface.Controllers;

public class FundingDecisionExportController : ControllerBase
{
private const string ApiVersion = "1.0";
private const string ApiVersion = ApiConstants.ApiVersion1;
private readonly ILogger<FundingDecisionExportController> _logger;
private readonly IFundingDecisionService _service;
private readonly IDiagnosticContext _diagnosticContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using CSC.PublicApi.Interface.Services;
/*
* API version 1.0
*/
using CSC.PublicApi.Interface.Services.V1;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ResearchFi.Query;
Expand All @@ -8,10 +11,11 @@
namespace CSC.PublicApi.Interface.Controllers;

[ApiController]
[ApiVersion(ApiConstants.ApiVersion1)]
[ApiVersion(ApiVersion)]
[Route("v{version:apiVersion}/")]
public class InfrastructureController : ControllerBase
{
private const string ApiVersion = ApiConstants.ApiVersion1;
private readonly ILogger<InfrastructureController> _logger;
private IInfrastructureService _infrastructureService;
private IInfrastructureServiceService _infrastructureServiceService;
Expand Down Expand Up @@ -39,6 +43,7 @@ public InfrastructureController(
/// <response code="401">Unauthorized.</response>
/// <response code="403">Forbidden.</response>
[HttpGet("infrastructures", Name = "GetInfrastructures")]
[MapToApiVersion(ApiVersion)]
[Authorize(Policy = ApiPolicies.Infrastructure.Read)]
[Produces(ApiConstants.ContentTypeJson)]
[Consumes(ApiConstants.ContentTypeJson)]
Expand Down Expand Up @@ -85,6 +90,7 @@ public async Task<IResult> GetInfrastructure(string urn)
/// <response code="401">Unauthorized.</response>
/// <response code="403">Forbidden.</response>
[HttpGet("infrastructures/services", Name = "GetServices")]
[MapToApiVersion(ApiVersion)]
[Authorize(Policy = ApiPolicies.Infrastructure.Read)]
[Produces(ApiConstants.ContentTypeJson)]
[Consumes(ApiConstants.ContentTypeJson)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using CSC.PublicApi.Interface.Services;
/*
* API version 1.0
*/
using CSC.PublicApi.Interface.Services.V1;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ResearchFi.Query;
Expand All @@ -8,10 +11,11 @@
namespace CSC.PublicApi.Interface.Controllers;

[ApiController]
[ApiVersion(ApiConstants.ApiVersion1)]
[ApiVersion(ApiVersion)]
[Route("v{version:apiVersion}/infrastructures-export")]
public class InfrastructureExportController : ControllerBase
{
private const string ApiVersion = ApiConstants.ApiVersion1;
private readonly ILogger<InfrastructureExportController> _logger;
private IInfrastructureService _infrastructureService;
private IInfrastructureServiceService _infrastructureServiceService;
Expand Down Expand Up @@ -39,6 +43,7 @@ public InfrastructureExportController(
/// <response code="401">Unauthorized.</response>
/// <response code="403">Forbidden.</response>
[HttpGet(Name = "GetInfrastructuresExport")]
[MapToApiVersion(ApiVersion)]
[Authorize(Policy = ApiPolicies.Infrastructure.Read)]
[Produces(ApiConstants.ContentTypeJson)]
[Consumes(ApiConstants.ContentTypeJson)]
Expand All @@ -64,6 +69,7 @@ public async Task<IEnumerable<Infrastructure>> Get([FromQuery] GetInfrastructure
/// <response code="401">Unauthorized.</response>
/// <response code="403">Forbidden.</response>
[HttpGet("services", Name = "GetInfrastructuresServicesExport")]
[MapToApiVersion(ApiVersion)]
[Authorize(Policy = ApiPolicies.Infrastructure.Read)]
[Produces(ApiConstants.ContentTypeJson)]
[Consumes(ApiConstants.ContentTypeJson)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using CSC.PublicApi.Interface.Services;
/*
* API version 1.0
*/
using CSC.PublicApi.Interface.Services.V1;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ResearchFi.Query;
Expand All @@ -12,8 +15,7 @@ namespace CSC.PublicApi.Interface.Controllers;
[Route("v{version:apiVersion}/organizations")]
public class OrganizationController : ControllerBase
{
private const string ApiVersion = "1.0";

private const string ApiVersion = ApiConstants.ApiVersion1;
private readonly ILogger<OrganizationController> _logger;
private IOrganizationService _service;
private readonly IDiagnosticContext _diagnosticContext;
Expand Down
Loading
Loading