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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ obj
/LearningHub.Nhs.WebUI.AutomatedUiTests/appsettings.Development.json
/OpenAPI/LearningHub.Nhs.OpenApi/appsettings.Development.json
/OpenAPI/LearningHub.Nhs.OpenApi/web.config
/AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj.user
/WebAPI/LearningHub.Nhs.API/LearningHub.Nhs.Api.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[Authorize]
[Route("Bookmark")]
[ApiController]
public class BookmarkController : Controller
public class BookmarkController : OpenApiControllerBase
{
private readonly IBookmarkService bookmarkService;

Expand All @@ -28,6 +28,7 @@ public BookmarkController(IBookmarkService bookmarkService)
this.bookmarkService = bookmarkService;
}

/// <summary>
/// <summary>
/// Gets all bookmarks by parent.
/// </summary>
Expand All @@ -36,11 +37,7 @@ public BookmarkController(IBookmarkService bookmarkService)
[Route("GetAllByParent")]
public async Task<IEnumerable<UserBookmarkViewModel>> GetAllByParent()
{
var accessToken = await this.HttpContext
.GetTokenAsync(OpenIdConnectParameterNames.AccessToken);

return await this.bookmarkService.GetAllByParent(
accessToken);
return await this.bookmarkService.GetAllByParent(this.TokenWithoutBearer);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,23 @@ public int? CurrentUserId
}
}
}

/// <summary>
/// Gets the bearer token from OAuth and removes "Bearer " prepend.
/// </summary>
public string TokenWithoutBearer
{
get
{
string accessToken = this.HttpContext.Request.Headers["Authorization"].ToString();

if (string.IsNullOrEmpty(accessToken))
{
throw new HttpResponseException($"No token provided please use OAuth", HttpStatusCode.Unauthorized);
}

return accessToken.StartsWith("Bearer ") ? accessToken.Substring("Bearer ".Length) : accessToken;
}
}
}
}
33 changes: 31 additions & 2 deletions OpenAPI/LearningHub.Nhs.OpenApi/SwaggerDefinitions/v1.3.0.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"openapi": "3.0.1",
"openapi": "3.0.2",
"info": {
"title": "LearningHub.NHS.OpenAPI",
"version": "1.3.0",
Expand Down Expand Up @@ -296,7 +296,7 @@
}
}
},
"/Resource/ActivityStatus/{activityStatusId}": {
"/Resource/User/{activityStatusId}": {
"get": {
"tags": [ "Resource" ],
"summary": "Get resource references by activity status",
Expand Down Expand Up @@ -341,6 +341,35 @@
}
}
}
},
"/Resource/User/Certificates": {
"get": {
"tags": [ "Resource" ],
"summary": "Get resource references where a major version has a certificate",
"operationId": "GetResourceReferencesByCertificates",
"parameters": [],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ResourceReferenceWithResourceDetailsViewModel"
}
}
}
}
},
"401": {
"description": "Unauthorized: User Id required."
},
"500": {
"description": "Internal server error: An unexpected error occurred while processing the request."
}
}
}
}
},
"components": {
Expand Down