Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds self links to signing data elements #986

Open
wants to merge 2 commits into
base: feature/signing
Choose a base branch
from
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
12 changes: 9 additions & 3 deletions src/Altinn.App.Api/Controllers/SigningController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Altinn.App.Api.Models;
using Altinn.App.Core.Features.Signing.Interfaces;
using Altinn.App.Core.Features.Signing.Models;
using Altinn.App.Core.Helpers;
using Altinn.App.Core.Internal.App;
using Altinn.App.Core.Internal.Instances;
using Altinn.App.Core.Internal.Process;
Expand Down Expand Up @@ -47,7 +48,7 @@ IProcessReader processReader
/// <param name="instanceOwnerPartyId">unique id of the party that this the owner of the instance</param>
/// <param name="instanceGuid">unique id to identify the instance</param>
/// <param name="language">The currently used language by the user (or null if not available)</param>
/// <returns>An object containing updated signing information</returns>
/// <returns>An object containing updated signee state</returns>
[HttpGet]
[ProducesResponseType(typeof(SingingStateResponse), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
Expand Down Expand Up @@ -108,10 +109,10 @@ public async Task<IActionResult> GetSigneesState(
/// <param name="instanceOwnerPartyId"></param>
/// <param name="instanceGuid"></param>
/// <param name="language"></param>
/// <returns></returns>
/// <returns>An object containing the documents to be signed</returns>
/// <exception cref="ApplicationConfigException"></exception>
[HttpGet("data-elements")]
[ProducesResponseType(typeof(SingingStateResponse), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(SigningDataElementsResponse), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<IActionResult> GetDataElements(
[FromRoute] string org,
Expand Down Expand Up @@ -141,6 +142,11 @@ public async Task<IActionResult> GetDataElements(
.Data.Where(x => signingConfiguration.DataTypesToSign.Contains(x.DataType))
.ToList();

foreach (DataElement dataElement in dataElements)
{
SelfLinkHelper.SetDataAppSelfLinks(instanceOwnerPartyId, instanceGuid, dataElement, Request);
}

SigningDataElementsResponse response = new() { DataElements = dataElements };

return Ok(response);
Expand Down
26 changes: 21 additions & 5 deletions test/Altinn.App.Api.Tests/OpenApi/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4693,27 +4693,27 @@
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/SingingStateResponse"
"$ref": "#/components/schemas/SigningDataElementsResponse"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/SingingStateResponse"
"$ref": "#/components/schemas/SigningDataElementsResponse"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/SingingStateResponse"
"$ref": "#/components/schemas/SigningDataElementsResponse"
}
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/SingingStateResponse"
"$ref": "#/components/schemas/SigningDataElementsResponse"
}
},
"text/xml": {
"schema": {
"$ref": "#/components/schemas/SingingStateResponse"
"$ref": "#/components/schemas/SigningDataElementsResponse"
}
}
}
Expand Down Expand Up @@ -7634,6 +7634,22 @@
},
"additionalProperties": false
},
"SigningDataElementsResponse": {
"required": [
"dataElements"
],
"type": "object",
"properties": {
"dataElements": {
"type": "array",
"items": {
"$ref": "#/components/schemas/DataElement"
},
"nullable": true
}
},
"additionalProperties": false
},
"SimpleInstance": {
"type": "object",
"properties": {
Expand Down
21 changes: 16 additions & 5 deletions test/Altinn.App.Api.Tests/OpenApi/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2859,19 +2859,19 @@ paths:
content:
text/plain:
schema:
$ref: '#/components/schemas/SingingStateResponse'
$ref: '#/components/schemas/SigningDataElementsResponse'
application/json:
schema:
$ref: '#/components/schemas/SingingStateResponse'
$ref: '#/components/schemas/SigningDataElementsResponse'
text/json:
schema:
$ref: '#/components/schemas/SingingStateResponse'
$ref: '#/components/schemas/SigningDataElementsResponse'
application/xml:
schema:
$ref: '#/components/schemas/SingingStateResponse'
$ref: '#/components/schemas/SigningDataElementsResponse'
text/xml:
schema:
$ref: '#/components/schemas/SingingStateResponse'
$ref: '#/components/schemas/SigningDataElementsResponse'
'400':
description: Bad Request
content:
Expand Down Expand Up @@ -4886,6 +4886,17 @@ components:
notificationSuccessful:
type: boolean
additionalProperties: false
SigningDataElementsResponse:
required:
- dataElements
type: object
properties:
dataElements:
type: array
items:
$ref: '#/components/schemas/DataElement'
nullable: true
additionalProperties: false
SimpleInstance:
type: object
properties:
Expand Down
Loading