Implement skeleton for patch document

This commit is contained in:
2025-01-31 10:19:55 +01:00
parent 3f3752c67b
commit 8b64dbac97
6 changed files with 108 additions and 3 deletions

View File

@ -39,6 +39,7 @@ paths:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/HelloResponse" $ref: "#/components/schemas/HelloResponse"
/signing-request/{id}: /signing-request/{id}:
get: get:
tags: tags:
@ -71,6 +72,41 @@ paths:
application/json: application/json:
schema: schema:
$ref: "#/components/schemas/ErrorResponse" $ref: "#/components/schemas/ErrorResponse"
/signing-request-document/{id}:
patch:
tags:
- signing-request-document
summary: Change some data in a signing request document
operationId: patchSigningRequestDocument
parameters:
- name: id
in: path
required: true
description: The ID of the signing request document
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/PatchSigningRequestDocumentRequest"
responses:
204:
description: "Signing request document was patched"
401:
description: "Unauthorized"
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
404:
description: "Signing request document was not found"
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
/signing-request-document/{id}/data: /signing-request-document/{id}/data:
get: get:
tags: tags:
@ -180,6 +216,20 @@ components:
confirmed: confirmed:
type: boolean type: boolean
PatchSigningRequestDocumentRequest:
type: object
required:
- op
- path
- value
properties:
op:
type: string
path:
type: string
value:
type: string
ErrorResponse: ErrorResponse:
type: object type: object
required: required:

View File

@ -94,7 +94,11 @@
<version>0.11.5</version> <version>0.11.5</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>com.github.java-json-tools</groupId>
<artifactId>json-patch</artifactId>
<version>1.13</version>
</dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>

View File

@ -0,0 +1,20 @@
package ch.dlmw.swisssignchallenge.controllers;
import ch.dlmw.swisssignchallenge.services.SigningRequestDocumentService;
import lombok.AllArgsConstructor;
import org.openapitools.api.SigningRequestDocumentApi;
import org.openapitools.model.PatchSigningRequestDocumentRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@RestController
@AllArgsConstructor
public class SigningRequestDocumentController implements SigningRequestDocumentApi {
private final SigningRequestDocumentService signingRequestDocumentService;
@Override
public ResponseEntity<Void> patchSigningRequestDocument(String id, PatchSigningRequestDocumentRequest patchSigningRequestDocumentRequest) {
signingRequestDocumentService.patchSigningRequestDocument(id, patchSigningRequestDocumentRequest);
return ResponseEntity.noContent().build();
}
}

View File

@ -63,8 +63,8 @@ public class JwtRequestFilter extends OncePerRequestFilter {
filterChain.doFilter(request, response); filterChain.doFilter(request, response);
} catch (Exception e) { } catch (Exception e) {
response.setContentType("application/json"); response.setContentType("application/json");
response.setStatus(HttpStatus.BAD_REQUEST.value()); response.setStatus(HttpStatus.UNAUTHORIZED.value());
response.getWriter().write(objectMapper.writeValueAsString(new ErrorResponse("Couldn't authenticate", HttpStatus.BAD_REQUEST.value()))); response.getWriter().write(objectMapper.writeValueAsString(new ErrorResponse("Couldn't authenticate", HttpStatus.UNAUTHORIZED.value())));
} }
} }

View File

@ -0,0 +1,7 @@
package ch.dlmw.swisssignchallenge.services;
import org.openapitools.model.PatchSigningRequestDocumentRequest;
public interface SigningRequestDocumentService {
void patchSigningRequestDocument(String id, PatchSigningRequestDocumentRequest patchSigningRequestDocumentRequest);
}

View File

@ -0,0 +1,24 @@
package ch.dlmw.swisssignchallenge.services.impl;
import ch.dlmw.swisssignchallenge.repositories.SigningRequestDocumentRepository;
import ch.dlmw.swisssignchallenge.services.SigningRequestDocumentService;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import org.openapitools.model.PatchSigningRequestDocumentRequest;
import org.springframework.stereotype.Service;
import java.util.UUID;
@Service
@AllArgsConstructor
public class SigningRequestDocumentServiceImpl implements SigningRequestDocumentService {
private final SigningRequestDocumentRepository signingRequestDocumentRepository;
private final ObjectMapper objectMapper;
@Override
public void patchSigningRequestDocument(String id, PatchSigningRequestDocumentRequest patchSigningRequestDocumentRequest) {
var document = signingRequestDocumentRepository.findById(UUID.fromString(id)).orElseThrow();
System.out.println(document.isConfirmed());
}
}