Skip to content

Commit

Permalink
feat: adapt to openApi standard
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaDel03 committed Jan 30, 2025
1 parent 0033ce0 commit a6ad8db
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
@Validated
public interface IChangeSetCTL {

@Operation(summary = "Transform Status check",description = "a check about Transform")
@Operation(summary = "Transform Status check",description = "a check about Transform", operationId = "getTransformChangeSet")
@ApiResponses(value = {
@ApiResponse(responseCode = "200",description = "Documents uploaded",content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE,schema = @Schema(implementation = ChangeSetResDTO.class))),
@ApiResponse(responseCode = "400",description = "Invalid parameters",content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE,schema = @Schema(implementation = ErrorResponseDTO.class))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public interface ITransformCTL {
produces = { MediaType.APPLICATION_JSON_VALUE },
consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }
)
@Operation(summary = "Aggiunta entità FHIR su MongoDB")
@Operation(summary = "Aggiunta entità FHIR su MongoDB", operationId = "createTransform", description = "Operation to create transform")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Creazione entità avvenuta con successo", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = PostDocsResDTO.class))),
@ApiResponse(responseCode = "400", description = "I parametri forniti non sono validi", content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE, schema = @Schema(implementation = ErrorResponseDTO.class))),
Expand Down Expand Up @@ -89,7 +89,7 @@ PostDocsResDTO uploadTransform(
produces = { MediaType.APPLICATION_JSON_VALUE },
consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }
)
@Operation(summary = "Aggiornamento entità FHIR su MongoDB")
@Operation(summary = "Aggiornamento entità FHIR su MongoDB", operationId = "updateTransform", description = "Operation to update transform")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Aggiornamento trasformata avvenuta con successo", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = PutDocsResDTO.class))),
@ApiResponse(responseCode = "400", description = "I parametri forniti non sono validi", content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE, schema = @Schema(implementation = ErrorResponseDTO.class))),
Expand All @@ -112,7 +112,7 @@ PutDocsResDTO updateTransform(
@DeleteMapping(
produces = { MediaType.APPLICATION_JSON_VALUE }
)
@Operation(summary = "Rimozione entità FHIR su MongoDB")
@Operation(summary = "Rimozione entità FHIR su MongoDB", operationId = "deleteTransform", description = "Operation to delete transform")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Cancellazione avvenuta con successo", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = DelDocsResDTO.class))),
@ApiResponse(responseCode = "400", description = "I parametri forniti non sono validi", content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE, schema = @Schema(implementation = ErrorResponseDTO.class))),
Expand All @@ -126,7 +126,7 @@ DelDocsResDTO deleteTransform(
) throws DocumentNotFoundException, OperationException;

@GetMapping(produces = { MediaType.APPLICATION_JSON_VALUE })
@Operation(summary = "Restituzione entità FHIR per URI")
@Operation(summary = "Restituzione entità FHIR per URI", operationId = "getTransformByUri", description = "Operation to get transform by uri")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Richiesta avvenuta con successo", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = GetDocsResDTO.class))),
@ApiResponse(responseCode = "400", description = "I parametri forniti non sono validi", content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE, schema = @Schema(implementation = ErrorResponseDTO.class))),
Expand All @@ -146,7 +146,7 @@ GetDocsResDTO getTransformByUri(
) throws DocumentNotFoundException, OperationException;

@GetMapping(value = API_GET_ONE_BY_ID, produces = { MediaType.APPLICATION_JSON_VALUE })
@Operation(summary = "Restituzione entità FHIR per ID")
@Operation(summary = "Restituzione entità FHIR per ID", operationId = "replaceTransformById", description = "Operation to replace transform by id")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Richiesta avvenuta con successo", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = GetDocByIdResDTO.class))),
@ApiResponse(responseCode = "400", description = "I parametri forniti non sono validi", content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE, schema = @Schema(implementation = ErrorResponseDTO.class))),
Expand All @@ -161,7 +161,7 @@ GetDocByIdResDTO getTransformById(
) throws OperationException, DocumentNotFoundException;

@GetMapping(value = API_PATH_ALL_VAR, produces = { MediaType.APPLICATION_JSON_VALUE })
@Operation(summary = "Restituzione di tutte le entità FHIR disponibili")
@Operation(summary = "Restituzione di tutte le entità FHIR disponibili", operationId = "getTransform", description = "Operation to get all transform")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Richiesta avvenuta con successo", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = GetDocsResDTO.class))),
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE, schema = @Schema(implementation = ErrorResponseDTO.class)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ public class LivenessCheckCTL implements HealthIndicator {
@GetMapping("/status")
@Operation(
summary = "Health check status",
description = "Health check endpoint."
description = "Health check endpoint.",
operationId = "health"
)
@ApiResponse(content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Health check OK", content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE)),
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE)) })
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE)),
})
public Health health() {
return Health.up().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
package it.finanze.sanita.fse2.ms.srvfhirmappingmanager.dto.response;


import io.swagger.v3.oas.annotations.media.Schema;
import it.finanze.sanita.fse2.ms.srvfhirmappingmanager.enums.FhirTypeEnum;
import it.finanze.sanita.fse2.ms.srvfhirmappingmanager.repository.entity.TransformETY;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

Expand All @@ -33,16 +36,44 @@
@AllArgsConstructor
@NoArgsConstructor
public class TransformDTO {


@Schema(maxLength = 255)
@Pattern(regexp = "^[a-zA-Z0-9-_]+$", message = "ID must contain only alphanumeric, dashes, or underscores")
private String id;

@Schema(maxLength = 255)
@Pattern(regexp = "^[a-zA-Z0-9-_]+$", message = "URI must contain only alphanumeric, dashes, or underscores")
private String uri;

@Schema(maxLength = 255)
@Pattern(regexp = "^[a-zA-Z0-9-_]+$", message = "Version must contain only alphanumeric, dashes, or underscores")
private String version;
private List<String> templateIdRoot;

@Schema(minLength = 1, maxLength = 100)
@Size(min = 1, max = 100)
private List<
@Size(max = 255)
@Pattern(regexp = "^[a-zA-Z0-9-_]+$", message = "Template ID must contain only alphanumeric, dashes, or underscores")
String
> templateIdRoot;

@Schema(maxLength = 255)
@Pattern(regexp = "^[a-zA-Z0-9-_]+$", message = "Content must contain only alphanumeric, dashes, or underscores")
private String content;

@Schema(maxLength = 255)
@Pattern(regexp = "^[a-zA-Z0-9-_]+$", message = "Filename must contain only alphanumeric, dashes, or underscores")
private String filename;
private FhirTypeEnum type;

@Schema(maxLength = 255)
private FhirTypeEnum type;

@Schema(format = "date-time", maxLength = 255)
private Date insertionDate;

@Schema(format = "date-time", maxLength = 255)
private Date lastUpdateDate;

private boolean deleted;

@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.Pattern;

/**
* Base response
*/
Expand All @@ -37,12 +39,14 @@ public class ResponseDTO implements AbstractDTO {
* Trace id log.
*/
@Schema(minLength = DEFAULT_STRING_MIN_SIZE, maxLength = DEFAULT_STRING_MAX_SIZE)
@Pattern(regexp = "^[a-zA-Z0-9-_]+$")
private String traceID;

/**
* Span id log.
*/
@Schema(minLength = DEFAULT_STRING_MIN_SIZE, maxLength = DEFAULT_STRING_MAX_SIZE)
@Pattern(regexp = "^[a-zA-Z0-9-_]+$")
private String spanID;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,29 @@
*/
package it.finanze.sanita.fse2.ms.srvfhirmappingmanager.dto.response.changes;

import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;
import it.finanze.sanita.fse2.ms.srvfhirmappingmanager.dto.response.TransformDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Value;

import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.List;

import static it.finanze.sanita.fse2.ms.srvfhirmappingmanager.utility.UtilsOA.OA_ANY_STRING_MAX;
import static it.finanze.sanita.fse2.ms.srvfhirmappingmanager.utility.UtilsOA.OA_ANY_STRING_MIN;
import static it.finanze.sanita.fse2.ms.srvfhirmappingmanager.utility.UtilsOA.*;
import static it.finanze.sanita.fse2.ms.srvfhirmappingmanager.utility.UtilsOA.OA_ARRAY_FILES_MAX;
import static it.finanze.sanita.fse2.ms.srvfhirmappingmanager.utility.ValidationUtility.DEFAULT_STRING_MAX_SIZE;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ChangeSetDTO {

@Size(max = DEFAULT_STRING_MAX_SIZE)
@Size(min = 0, max = DEFAULT_STRING_MAX_SIZE)
@Pattern(regexp = "^[a-zA-Z0-9-_]+$")
private String id;

Payload description;
Expand All @@ -44,6 +49,11 @@ public static class Payload {
/**
* The resource extension identifier
*/
@ArraySchema(
minItems = OA_ARRAY_FILES_MIN,
maxItems = OA_ARRAY_FILES_MAX,
schema = @Schema(implementation = String.class)
)
@Size(min = OA_ANY_STRING_MIN, max = OA_ANY_STRING_MAX)
List<String> templateIdRoot;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public class ChangeSetResDTO {
*/
@Schema(minLength = DEFAULT_STRING_MIN_SIZE, maxLength = DEFAULT_STRING_MAX_SIZE)
private String spanID;

@Schema(format = "date-time", maxLength = 255)
private Date lastUpdate;
@Schema(format = "date-time", maxLength = 255)
private Date timestamp;

@ArraySchema(minItems = DEFAULT_ARRAY_MIN_SIZE, maxItems = DEFAULT_ARRAY_MAX_SIZE, uniqueItems = true)
Expand All @@ -61,10 +62,11 @@ public class ChangeSetResDTO {
@ArraySchema(minItems = DEFAULT_ARRAY_MIN_SIZE, maxItems = DEFAULT_ARRAY_MAX_SIZE, uniqueItems = true)
private List<ChangeSetDTO> deletions;

@Schema(minLength = DEFAULT_STRING_MIN_SIZE, maxLength = 10000)
@Size(min = 0, max = 10000)
@Schema(minLength = DEFAULT_STRING_MIN_SIZE, maxLength = 20000)
@Size(min = 0, max = 20000)
private long totalNumberOfElements;

@Schema(minLength = 0, maxLength = 10000)
private long collectionSize;

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@
*/
package it.finanze.sanita.fse2.ms.srvfhirmappingmanager.dto.response.crud;

import io.swagger.v3.oas.annotations.media.Schema;
import it.finanze.sanita.fse2.ms.srvfhirmappingmanager.dto.response.base.ResponseDTO;
import it.finanze.sanita.fse2.ms.srvfhirmappingmanager.dto.response.info.LogTraceInfoDTO;
import lombok.Getter;

import javax.validation.constraints.Size;

@Getter
public class DelDocsResDTO extends ResponseDTO {

@Schema(format = "int32", minLength = 0, maxLength = 10000)
private final int deletedItems;

public DelDocsResDTO(final LogTraceInfoDTO traceInfo, int deletedItems) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class GetDocsResDTO extends ResponseDTO {
)
private final List<TransformDTO> items;

@Schema(format = "int64", minLength = OA_ARRAY_FILES_MIN, maxLength = OA_ARRAY_FILES_MAX)
private final long numberOfItems;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package it.finanze.sanita.fse2.ms.srvfhirmappingmanager.dto.response.crud;

import io.swagger.v3.oas.annotations.media.Schema;
import it.finanze.sanita.fse2.ms.srvfhirmappingmanager.dto.response.base.ResponseDTO;
import it.finanze.sanita.fse2.ms.srvfhirmappingmanager.dto.response.info.LogTraceInfoDTO;
import lombok.Getter;
Expand All @@ -25,6 +26,7 @@
@Getter
public class PostDocsResDTO extends ResponseDTO {

@Schema(format = "int32", minLength = 0, maxLength = 10000)
private final int insertedItems;

public PostDocsResDTO(final LogTraceInfoDTO traceInfo, int insertedItems) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
*/
package it.finanze.sanita.fse2.ms.srvfhirmappingmanager.dto.response.crud;

import io.swagger.v3.oas.annotations.media.Schema;
import it.finanze.sanita.fse2.ms.srvfhirmappingmanager.dto.response.base.ResponseDTO;
import it.finanze.sanita.fse2.ms.srvfhirmappingmanager.dto.response.info.LogTraceInfoDTO;
import lombok.Getter;

@Getter
public class PutDocsResDTO extends ResponseDTO {

@Schema(format = "int32", minLength = 0, maxLength = 10000)
private final int updatedItems;

public PutDocsResDTO(final LogTraceInfoDTO traceInfo, int updatedItems) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,6 @@
@Data
@EqualsAndHashCode(callSuper = true)
public class ErrorResponseDTO extends ResponseDTO {

/**
* Trace id log.
*/
@Schema(description = "Indentificativo univoco della richiesta dell'utente")
@Size(min = 0, max = 100)
private String traceID;

/**
* Span id log.
*/
@Schema(description = "Indentificativo univoco di un task della richiesta dell'utente (differisce dal traceID solo in caso di chiamate sincrone in cascata)")
@Size(min = 0, max = 100)
private String spanID;

@Schema(description = "Identificativo del problema verificatosi")
@Size(min = 0, max = 100)
Expand All @@ -63,18 +49,15 @@ public class ErrorResponseDTO extends ResponseDTO {
@Size(min = 0, max = 1000)
private String detail;

@Schema(description = "Stato http")
@Min(value = 100)
@Max(value = 599)
@Schema(format = "int32",description = "Stato http", minLength = 100, maxLength = 599)
private Integer status;

@Schema(description = "URI che potrebbe fornire ulteriori informazioni riguardo l'occorrenza del problema")
@Size(min = 0, max = 255)
private String instance;

public ErrorResponseDTO(final LogTraceInfoDTO traceInfo, final String inType, final String inTitle, final String inDetail, final Integer inStatus, final String inInstance) {
traceID = traceInfo.getTraceID();
spanID = traceInfo.getSpanID();
super(traceInfo);
type = inType;
title = inTitle;
detail = inDetail;
Expand All @@ -83,8 +66,7 @@ public ErrorResponseDTO(final LogTraceInfoDTO traceInfo, final String inType, fi
}

public ErrorResponseDTO(final LogTraceInfoDTO traceInfo) {
traceID = traceInfo.getTraceID();
spanID = traceInfo.getSpanID();
super(traceInfo);
}

}

0 comments on commit a6ad8db

Please sign in to comment.