Skip to content

Commit

Permalink
feat: openApi compliancy
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaDel03 committed Jan 31, 2025
1 parent 99f566c commit 39744c0
Show file tree
Hide file tree
Showing 18 changed files with 172 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Date;

import static it.finanze.sanita.fse2.ms.edssrvdictionary.config.Constants.Logs.*;
Expand All @@ -58,6 +59,7 @@ ChangeSetChunkDTO changeSetChunks(
@RequestParam(value=API_QP_LAST_UPDATE, required = false)
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
@NoFutureDate(message = ERR_VAL_FUTURE_DATE)
@Schema(maxLength = 50)
Date lastUpdate
) throws OperationException;

Expand All @@ -68,7 +70,8 @@ ChangeSetChunkDTO changeSetChunks(
@Tag(name = API_CHANGESET_CHUNKS_TAG)
@Operation(
summary = "Restituisce un chunk dato indice e identificativo snapshot (solo-inserimenti)",
description = "Servizio che consente di restituire le terminologie presenti nel chunk di un dato snapshot."
description = "Servizio che consente di restituire le terminologie presenti nel chunk di un dato snapshot.",
operationId = "listTerminologyFromSnapshotIns"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Richiesta terminologie avvenuta con successo", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = GetTermsInsDTO.class))),
Expand All @@ -81,9 +84,11 @@ GetTermsInsDTO getTermsByChunkIns(
@Parameter(description = "Identificatore documento (snapshot)")
@NotBlank(message = ERR_VAL_ID_BLANK)
@ValidObjectId(message = ERR_VAL_ID_NOT_VALID)
@Size(max = 10000)
String id,
@PathVariable
@Parameter(description = "Indice chunk richiesto (eg. 0, 1, 2...)")
@Size(min = 0, max = 10000000)
int idx
) throws OutOfRangeException, DocumentNotFoundException, DataIntegrityException, OperationException;

Expand All @@ -94,7 +99,8 @@ GetTermsInsDTO getTermsByChunkIns(
@Tag(name = API_CHANGESET_CHUNKS_TAG)
@Operation(
summary = "Restituisce un chunk dato indice e identificativo snapshot (solo-cancellazioni)",
description = "Servizio che consente di restituire le terminologie presenti nel chunk di un dato snapshot."
description = "Servizio che consente di restituire le terminologie presenti nel chunk di un dato snapshot.",
operationId = "listTerminologyFromSnapshotDel"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Richiesta terminologie avvenuta con successo", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = GetTermsDelDTO.class))),
Expand All @@ -107,9 +113,11 @@ GetTermsDelDTO getTermsByChunkDel(
@Parameter(description = "Identificatore documento (snapshot)")
@NotBlank(message = ERR_VAL_ID_BLANK)
@ValidObjectId(message = ERR_VAL_ID_NOT_VALID)
@Size(max = 10000)
String id,
@PathVariable
@Parameter(description = "Indice chunk richiesto (eg. 0, 1, 2...)")
@Size(min = 0, max = 100000000)
int idx
) throws OutOfRangeException, DocumentNotFoundException, DataIntegrityException, OperationException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Date;

import static it.finanze.sanita.fse2.ms.edssrvdictionary.config.Constants.Logs.*;
Expand All @@ -56,7 +59,8 @@ public interface ITerminologyCTL {
)
@Operation(
summary = "Restituisce un terminology dato il suo identificativo",
description = "Servizio che consente di ritornare una terminologia dato il suo identificativo."
description = "Servizio che consente di ritornare una terminologia dato il suo identificativo.",
operationId = "listTerminologiesById"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Documento presente sul database", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = GetDocsResDTO.class))),
Expand All @@ -69,6 +73,7 @@ GetDocsResDTO getTerminologyById(
@Parameter(description = "Identificatore documento")
@NotBlank(message = ERR_VAL_ID_BLANK)
@ValidObjectId(message = ERR_VAL_ID_NOT_VALID)
@Size(max = 255)
String id
) throws OperationException, DocumentNotFoundException;

Expand All @@ -78,7 +83,8 @@ GetDocsResDTO getTerminologyById(
)
@Operation(
summary = "Aggiunge terminologie attraverso un file CSV",
description = "Servizio che consente di aggiungere terminologie sulla base dati caricando un file csv."
description = "Servizio che consente di aggiungere terminologie sulla base dati caricando un file csv.",
operationId = "addTerminologiesFromCsv"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Documenti caricati correttamente", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = PostDocsResDTO.class))),
Expand All @@ -89,9 +95,11 @@ GetDocsResDTO getTerminologyById(
@ResponseStatus(HttpStatus.CREATED)
PostDocsResDTO uploadTerminologies(
@RequestPart
@Parameter(description = "CSV contenente le terminologie da inserire (e.g 2.16.840.1.113883.1.11.1.csv)")
@Parameter(description = "CSV contenente le terminologie da inserire (e.g 2.16.840.1.113883.1.11.1.csv)",
schema = @Schema(type = "string", format = "binary", maxLength = 30000000)) //30MB file max
MultipartFile file,
@Parameter(description = "Versione del dizionario")
@Size(max = 255)
String version,
@Parameter(description = "Data di rilascio del dizionario")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
Expand All @@ -105,7 +113,8 @@ PostDocsResDTO uploadTerminologies(
)
@Operation(
summary = "Restituisce le terminologie appartenenti al system richiesto con paginazione",
description = "Servizio che restituisce tutte le terminologie appartenenti ad un certo system con paginazione"
description = "Servizio che restituisce tutte le terminologie appartenenti ad un certo system con paginazione",
operationId = "listTerminologiesFromSystem"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Documenti restituite correttamente", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = GetDocsPageResDTO.class))),
Expand All @@ -117,12 +126,17 @@ GetDocsPageResDTO getTerminologies(
@PathVariable
@Parameter(description = "Identificatore del dizionario")
@NotBlank(message = ERR_VAL_SYSTEM_BLANK)
@Size(max = 10000)
String system,
@RequestParam(API_QP_PAGE)
@Parameter(description = "Indice pagina richiesto (eg. 0, 1, 2...)")
@Min(0)
@Max(Integer.MAX_VALUE)
int page,
@RequestParam(API_QP_LIMIT)
@Parameter(description = "Limite documenti per pagina (eg. 10, 20 ...)")
@Min(0)
@Max(Integer.MAX_VALUE)
int limit
) throws OperationException, DocumentNotFoundException, OutOfRangeException;

Expand All @@ -132,7 +146,8 @@ GetDocsPageResDTO getTerminologies(
)
@Operation(
summary = "Modifica terminologie attraverso un file CSV",
description = "Servizio che consente di aggiungere una nuova versione per terminologie già presenti sulla base dati caricando un file csv."
description = "Servizio che consente di aggiungere una nuova versione per terminologie già presenti sulla base dati caricando un file csv.",
operationId = "addVersioneFromCsv"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Documenti caricati correttamente", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = PutDocsResDTO.class))),
Expand All @@ -144,9 +159,11 @@ GetDocsPageResDTO getTerminologies(
@ResponseStatus(HttpStatus.CREATED)
PutDocsResDTO updateTerminologies(
@RequestPart
@Parameter(description = "CSV contenente le terminologie da inserire (e.g 2.16.840.1.113883.1.11.1.csv)")
@Parameter(description = "CSV contenente le terminologie da inserire (e.g 2.16.840.1.113883.1.11.1.csv)",
schema = @Schema(type = "string", format = "binary", maxLength = 30000000)) //30MB file max
MultipartFile file,
@Parameter(description = "Versione del dizionario incrementata rispetto alla precedente")
@Size(max = 10000)
String version,
@Parameter(description = "Data di rilascio del dizionario incrementata rispetto alla precedente")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
Expand All @@ -160,7 +177,8 @@ PutDocsResDTO updateTerminologies(
)
@Operation(
summary = "Cancellazione terminologie attraverso il system",
description = "Servizio che consente di cancellare un certo system dalla base dati"
description = "Servizio che consente di cancellare un certo system dalla base dati",
operationId = "removeTerminologyBySystem"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Documenti cancellati correttamente", content = @Content(mediaType = APPLICATION_JSON_VALUE, schema = @Schema(implementation = DelDocsResDTO.class))),
Expand All @@ -172,6 +190,7 @@ DelDocsResDTO deleteTerminologies(
@PathVariable
@Parameter(description = "Identificatore del dizionario")
@NotBlank(message = ERR_VAL_SYSTEM_BLANK)
@Size(max = 10000)
String system
) throws OperationException, DocumentNotFoundException, DataIntegrityException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ public class TerminologyDocumentDTO implements Serializable {
private static final long serialVersionUID = -7764465063914528589L;


@Schema(maxLength = DEFAULT_STRING_MAX_SIZE)
@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String id;
@Schema(maxLength = DEFAULT_STRING_MAX_SIZE)
@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String system;
@Schema(maxLength = DEFAULT_STRING_MAX_SIZE)
@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String version;
@Schema(maxLength = DEFAULT_STRING_MAX_SIZE)
@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String code;
@Schema(maxLength = DEFAULT_STRING_MAX_SIZE)
@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String description;
@Schema(format = "date-time", maxLength = 50)
private OffsetDateTime releaseDate;
@Schema(format = "date-time", maxLength = 50)
private OffsetDateTime insertionDate;
@Schema(format = "date-time", maxLength = 50)
private OffsetDateTime lastUpdateDate;

public static TerminologyDocumentDTO fromEntity(TerminologyETY e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,40 @@
*/
package it.finanze.sanita.fse2.ms.edssrvdictionary.dto.csv;

import io.swagger.v3.oas.annotations.media.Schema;
import org.apache.commons.lang3.StringUtils;

import com.opencsv.bean.CsvBindByName;

import lombok.Data;

import static it.finanze.sanita.fse2.ms.edssrvdictionary.utility.ValidationUtility.DEFAULT_STRING_MAX_SIZE;

@Data
public class TerminologyBuilderDTO {

@CsvBindByName(column = "Code")
@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String code;

@CsvBindByName(column = "Display")
@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String display;

@CsvBindByName(column = "CodeSystem")
@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String codeSystem;

@CsvBindByName(column = "DisplayName")
@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String displayName;

@CsvBindByName(column = "status")
@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String status;

@CsvBindByName(column = "Not Selectable")
@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private boolean notSelectable;

public String getDescription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@
*/
package it.finanze.sanita.fse2.ms.edssrvdictionary.dto.csv.vocabulary;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;

import static it.finanze.sanita.fse2.ms.edssrvdictionary.utility.ValidationUtility.DEFAULT_STRING_MAX_SIZE;

@Data
@Builder
public class TerminologyFileEntryDTO {

@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String code;


@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String description;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@

import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;
import lombok.Setter;

import static it.finanze.sanita.fse2.ms.edssrvdictionary.utility.ValidationUtility.DEFAULT_STRING_MAX_SIZE;

@Data
@Builder
@Setter
public class VocabularyDTO {

@Schema(minLength = 0, maxLength = DEFAULT_STRING_MAX_SIZE)
private String system;

List<TerminologyFileEntryDTO> entryDTO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
*/
package it.finanze.sanita.fse2.ms.edssrvdictionary.dto.response.base;

import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import io.swagger.v3.oas.annotations.media.Schema;
import it.finanze.sanita.fse2.ms.edssrvdictionary.dto.AbstractDTO;
import it.finanze.sanita.fse2.ms.edssrvdictionary.dto.response.log.LogTraceInfoDTO;
import lombok.Getter;
import lombok.Setter;

import static it.finanze.sanita.fse2.ms.edssrvdictionary.utility.ValidationUtility.DEFAULT_STRING_MAX_SIZE;
import static it.finanze.sanita.fse2.ms.edssrvdictionary.utility.ValidationUtility.DEFAULT_STRING_MIN_SIZE;

/**
*
*
Expand All @@ -30,13 +35,13 @@ public class ResponseDTO implements AbstractDTO {
/**
* Trace id log.
*/
@Size(min = 0, max = 100)
@Schema(minLength = DEFAULT_STRING_MIN_SIZE, maxLength = DEFAULT_STRING_MAX_SIZE)
private String traceID;

/**
* Span id log.
*/
@Size(min = 0, max = 100)
@Schema(minLength = DEFAULT_STRING_MIN_SIZE, maxLength = DEFAULT_STRING_MAX_SIZE)
private String spanID;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
*/
package it.finanze.sanita.fse2.ms.edssrvdictionary.dto.response.changes;

import io.swagger.v3.oas.annotations.media.Schema;
import it.finanze.sanita.fse2.ms.edssrvdictionary.dto.response.base.ResponseDTO;
import it.finanze.sanita.fse2.ms.edssrvdictionary.dto.response.changes.data.snapshot.ChunksDTO;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.util.Date;

/**
Expand All @@ -27,25 +31,17 @@
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ChangeSetChunkDTO {

/**
* Trace id log.
*/
private String traceID;

/**
* Span id log.
*/
private String spanID;
public class ChangeSetChunkDTO extends ResponseDTO {

/**
* Last update date to consider while retrieving the change set items
*/
@Schema(format = "date-time", maxLength = 50)
private Date lastUpdate;
/**
* The response date-time (usually used as the next lastUpdate)
*/
@Schema(format = "date-time", maxLength = 50)
private Date timestamp;

/**
Expand All @@ -56,10 +52,16 @@ public class ChangeSetChunkDTO {
/**
* The total number of items returned (inserted/modified/deleted)
*/
@Schema(format = "int64")
@Min(0)
@Max(Integer.MAX_VALUE)
private long totalNumberOfElements;

/**
* The current active collection items
*/
@Schema(format = "int64")
@Min(0)
@Max(Integer.MAX_VALUE)
private long collectionSize;
}
Loading

0 comments on commit 39744c0

Please sign in to comment.