Skip to content

Commit

Permalink
fix swagger error
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudFonzam committed Jul 10, 2023
1 parent abbcfb0 commit 1a97bb0
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 27 deletions.
14 changes: 8 additions & 6 deletions src/main/java/org/isf/accounting/rest/BillController.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;

Expand Down Expand Up @@ -200,8 +202,8 @@ public ResponseEntity<FullBillDTO> updateBill(@PathVariable Integer id, @Request
* @throws OHServiceException
*/
@GetMapping(value = "/bills", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<BillDTO>> searchBills(@RequestParam(value = "datefrom") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") LocalDateTime dateFrom,
@RequestParam(value = "dateto") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") LocalDateTime dateTo,
public ResponseEntity<List<BillDTO>> searchBills(@RequestParam(value = "datefrom") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") @Schema(implementation = String.class) LocalDateTime dateFrom,
@RequestParam(value = "dateto") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") @Schema(implementation = String.class) LocalDateTime dateTo,
@RequestParam(value = "patient_code", required = false, defaultValue = "") Integer code) throws OHServiceException {

List<Bill> bills;
Expand Down Expand Up @@ -236,8 +238,8 @@ public ResponseEntity<List<BillDTO>> searchBills(@RequestParam(value = "datefrom
*/
@GetMapping(value = "/bills/payments", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<BillPaymentsDTO>> searchBillsPayments(
@RequestParam(value="datefrom") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") LocalDateTime dateFrom,
@RequestParam(value="dateto") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") LocalDateTime dateTo,
@RequestParam(value="datefrom") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") @Schema(implementation = String.class) LocalDateTime dateFrom,
@RequestParam(value="dateto") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") @Schema(implementation = String.class) LocalDateTime dateTo,
@RequestParam(value="patient_code", required=false, defaultValue="") Integer code) throws OHServiceException {
LOGGER.info("Get Payments datefrom: {} dateTo: {} patient: {}", dateFrom, dateTo, code);

Expand Down Expand Up @@ -372,8 +374,8 @@ public ResponseEntity<List<BillDTO>> getPendingBills(@RequestParam(value="patien
* @throws OHServiceException
*/
@PostMapping(value = "/bills/search/by/item", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<BillDTO>> searchBills(@RequestParam(value="datefrom") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") LocalDateTime dateFrom,
@RequestParam(value="dateto")@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") LocalDateTime dateTo,
public ResponseEntity<List<BillDTO>> searchBills(@RequestParam(value="datefrom") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") @Schema(implementation = String.class) LocalDateTime dateFrom,
@RequestParam(value="dateto")@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") @Schema(implementation = String.class) LocalDateTime dateTo,
@RequestBody BillItemsDTO billItemDTO) throws OHServiceException {

BillItems billItem = billItemsMapper.map2Model(billItemDTO);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/isf/admission/rest/AdmissionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand Down Expand Up @@ -207,8 +207,8 @@ public ResponseEntity<AdmissionDTO> getCurrentAdmission(@RequestParam("patientCo
@GetMapping(value = "/admissions/admittedPatients", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<AdmittedPatientDTO>> getAdmittedPatients(
@RequestParam(name = "searchterms", defaultValue = "", required = false) String searchTerms,
@RequestParam(name = "admissionrange", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @Parameter(schema = @Schema(type = "String[]")) LocalDateTime[] admissionRange,
@RequestParam(name = "dischargerange", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @Parameter(schema = @Schema(type = "String[]")) LocalDateTime[] dischargeRange)
@RequestParam(name = "admissionrange", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @ArraySchema(schema = @Schema(implementation = String.class)) LocalDateTime[] admissionRange,
@RequestParam(name = "dischargerange", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @ArraySchema(schema = @Schema(implementation = String.class)) LocalDateTime[] dischargeRange)
throws OHServiceException {
LOGGER.info("Get admitted patients search terms: {}", searchTerms);
if (admissionRange != null && admissionRange.length == 2) {
Expand All @@ -235,7 +235,7 @@ public ResponseEntity<List<AdmittedPatientDTO>> getAdmittedPatients(
*/
@GetMapping(value = "/admissions", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Page<AdmissionDTO>> getAdmissions(
@RequestParam(name = "admissionrange") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime[] admissionRange,
@RequestParam(name = "admissionrange") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @ArraySchema(schema = @Schema(implementation = String.class)) LocalDateTime[] admissionRange,
@RequestParam(value = "page", required = false, defaultValue = "0") int page,
@RequestParam(value = "size", required = false, defaultValue = DEFAULT_PAGE_SIZE) int size,
@RequestParam(value = "paged", required = false, defaultValue = "false") boolean paged)
Expand Down Expand Up @@ -269,7 +269,7 @@ public ResponseEntity<Page<AdmissionDTO>> getAdmissions(
*/
@GetMapping(value = "/discharges", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Page<AdmissionDTO>> getDischarges(
@RequestParam(name = "dischargerange") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime[] dischargeRange,
@RequestParam(name = "dischargerange") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @ArraySchema(schema = @Schema(implementation = String.class)) LocalDateTime[] dischargeRange,
@RequestParam(value = "page", required = false, defaultValue = "0") int page,
@RequestParam(value = "size", required = false, defaultValue = DEFAULT_PAGE_SIZE) int size)
throws OHServiceException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.annotations.security.SecuritySchemes;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
Expand All @@ -40,18 +41,20 @@
import io.swagger.v3.oas.models.servers.Server;

@Configuration
@SecurityScheme(
@SecuritySchemes({
@SecurityScheme(
name = "bearerAuth",
type = SecuritySchemeType.HTTP,
bearerFormat = "JWT",
scheme = "bearer"
)
public class SpringFoxConfig {
})
public class OpenAPIConfiguration {

@Bean
public OpenAPI springShopOpenAPI() {
return new OpenAPI().addSecurityItem(
new SecurityRequirement().addList("Bearer Authentication"))
new SecurityRequirement().addList("bearerAuth"))
.info(new Info().title("OH 2.0 Api Documentation")
.description("OH 2.0 Api Documentation")
.version("1.0").contact(new Contact().name("ApiInfo.DEFAULT_CONTACT"))
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/isf/lab/dto/LaboratoryDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class LaboratoryDTO {
@Schema(description = "Laboratory Code")
private Integer code;

@Schema(description = "Laboratory Material", ref = "Blood")
@Schema(description = "Laboratory Material", example = "Blood")
private String material;

@Schema(description = "Laboratory Exam")
Expand All @@ -56,7 +56,7 @@ public class LaboratoryDTO {
@Schema(description = "lock", example = "0")
private int lock;

@Schema(description = "Laboratory Note", ref = "Note by laboratorist")
@Schema(description = "Laboratory Note", example = "Note by laboratorist")
private String note;

@Schema(description = "Laboratory Patient Code")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.security.SecurityRequirement;
Expand Down Expand Up @@ -134,18 +135,19 @@ public ResponseEntity<MalnutritionDTO> updateMalnutrition(@RequestBody @Valid Ma

/**
* Deletes a given {@link Malnutrition}.
* @param malnutritionDTO - the malnutrition to delete.
* @param code - the code of malnutrition to delete.
* @return {@code true} if the malnutrition has been deleted, {@code false} otherwise.
* @throws OHServiceException
*/
@DeleteMapping(value = "/malnutritions", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Boolean> deleteMalnutrition(@RequestBody @Valid MalnutritionDTO malnutritionDTO) throws OHServiceException{
List<Malnutrition> malnutritions = manager.getMalnutrition(String.valueOf(malnutritionDTO.getAdmission().getId()));
public ResponseEntity<Boolean> deleteMalnutrition(@RequestParam int code) throws OHServiceException{
Malnutrition malNutri = manager.getMalnutrition(code);
List<Malnutrition> malnutritions = manager.getMalnutrition(String.valueOf(malNutri.getAdmission().getId()));
List<Malnutrition> matchedMalnutritions = new ArrayList<>();
if (malnutritions != null) {
matchedMalnutritions = malnutritions
.stream()
.filter(malnutrition -> malnutrition.getCode() == malnutritionDTO.getCode())
.filter(malnutrition -> malnutrition.getCode() == code)
.collect(Collectors.toList());
}
if (matchedMalnutritions.isEmpty()) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/isf/opd/rest/OpdController.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;

Expand Down Expand Up @@ -282,8 +283,8 @@ public ResponseEntity<List<OpdDTO>> getOpdToDayOrWeek(@RequestParam(name="oneWee
*/
@GetMapping(value = "/opds/search", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Page<OpdDTO>> getOpdByDates(
@RequestParam(value = "dateFrom") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate dateFrom,
@RequestParam(value = "dateTo") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDate dateTo,
@RequestParam(value = "dateFrom") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @Schema(implementation = String.class) LocalDate dateFrom,
@RequestParam(value = "dateTo") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @Schema(implementation = String.class) LocalDate dateTo,
@RequestParam(value = "diseaseTypeCode", required = false) String diseaseTypeCode,
@RequestParam(value = "diseaseCode", required = false) String diseaseCode,
@RequestParam(value = "ageFrom", required = false, defaultValue = "0") Integer ageFrom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class PatientConsensusController {
@Autowired
protected PatientConsensusMapper mapper;

@GetMapping(value = "/{patientId}", produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(value = "/patientConsensus/{patientId}", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<PatientConsensusDTO> getPatientConsensus(@PathVariable Integer patientId) throws OHServiceException {
LOGGER.info("Retrieving patient consensus: {}", patientId);
Optional<PatientConsensus> patientConsensus = manager.getPatientConsensusByUserId(patientId);
Expand All @@ -68,7 +68,7 @@ ResponseEntity<PatientConsensusDTO> getPatientConsensus(@PathVariable Integer pa
return ResponseEntity.ok(patientDTO);
}

@PutMapping(value = "/{patientId}", produces = MediaType.APPLICATION_JSON_VALUE)
@PutMapping(value = "/patientConsensus/{patientId}", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<PatientConsensusDTO> updatePatientConsensus(@PathVariable Integer patientId, @RequestBody PatientConsensusDTO patientConsensus)
throws OHServiceException {
LOGGER.info("Update patient consensus by id: {}", patientId);
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/isf/visits/dto/VisitDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.validation.constraints.NotNull;

import org.isf.patient.dto.PatientDTO;
import org.isf.ward.dto.WardDTO;
import org.isf.ward.model.Ward;

import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -51,7 +52,7 @@ public class VisitDTO {
private boolean sms;

@Schema(description = "ward of the visit")
private Ward ward;
private WardDTO ward;

@Schema(description = "duration of the visit")
private Integer duration;
Expand All @@ -72,11 +73,11 @@ public LocalDateTime getDate() {
return this.date;
}

public Ward getWard() {
public WardDTO getWard() {
return ward;
}

public void setWard(Ward ward) {
public void setWard(WardDTO ward) {
this.ward = ward;
}

Expand Down

0 comments on commit 1a97bb0

Please sign in to comment.