Skip to content

Commit

Permalink
Merge pull request eclipse-tractusx#516 from FraunhoferISST/fix/swagg…
Browse files Browse the repository at this point in the history
…er_ui

fix: swagger_ui inconsistencies
  • Loading branch information
tom-rm-meyer-ISST authored Jul 24, 2024
2 parents 1213c58 + c8aeec1 commit b277446
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@

package org.eclipse.tractusx.puris.backend.delivery.controller;

import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import javax.management.openmbean.KeyAlreadyExistsException;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Validator;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.puris.backend.common.util.PatternStore;
import org.eclipse.tractusx.puris.backend.delivery.domain.model.OwnDelivery;
import org.eclipse.tractusx.puris.backend.delivery.domain.model.ReportedDelivery;
Expand All @@ -47,24 +44,16 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Validator;
import lombok.extern.slf4j.Slf4j;
import javax.management.openmbean.KeyAlreadyExistsException;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

@RestController
@RequestMapping("delivery")
Expand Down Expand Up @@ -119,10 +108,10 @@ public List<DeliveryDto> getAllDeliveries(String ownMaterialNumber, Optional<Str
@ResponseBody
@Operation(summary = "Creates a new delivery")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Delivery was created."),
@ApiResponse(responseCode = "400", description = "Malformed or invalid request body."),
@ApiResponse(responseCode = "409", description = "Delivery already exists."),
@ApiResponse(responseCode = "500", description = "Internal Server Error.")
@ApiResponse(responseCode = "201", description = "Delivery was created."),
@ApiResponse(responseCode = "400", description = "Malformed or invalid request body.", content = @Content),
@ApiResponse(responseCode = "409", description = "Delivery already exists.", content = @Content),
@ApiResponse(responseCode = "500", description = "Internal Server Error.", content = @Content)
})
@ResponseStatus(HttpStatus.CREATED)
public DeliveryDto createDelivery(@RequestBody DeliveryDto deliveryDto) {
Expand Down Expand Up @@ -153,12 +142,12 @@ public DeliveryDto createDelivery(@RequestBody DeliveryDto deliveryDto) {
@PutMapping()
@Operation(summary = "Updates a delivery by its UUID")
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "Delivery was updated."),
@ApiResponse(responseCode = "400", description = "Malformed or invalid request body."),
@ApiResponse(responseCode = "404", description = "Delivery does not exist."),
@ApiResponse(responseCode = "500", description = "Internal Server Error.")
@ApiResponse(responseCode = "202", description = "Delivery was updated."),
@ApiResponse(responseCode = "400", description = "Malformed or invalid request body.", content = @Content),
@ApiResponse(responseCode = "404", description = "Delivery does not exist.", content = @Content),
@ApiResponse(responseCode = "500", description = "Internal Server Error.", content = @Content)
})
@ResponseStatus(HttpStatus.OK)
@ResponseStatus(HttpStatus.ACCEPTED)
public DeliveryDto updateDelivery(@RequestBody DeliveryDto dto) {
OwnDelivery updatedDelivery = ownDeliveryService.update(convertToEntity(dto));
if (updatedDelivery == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.eclipse.tractusx.puris.backend.delivery.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -49,12 +50,13 @@ public class DeliveryRequestApiController {
private final Pattern urnPattern = PatternStore.URN_OR_UUID_PATTERN;


@Operation(summary = "This endpoint receives the Delivery Information Submodel 2.0.0 requests")
@Operation(summary = "This endpoint receives the Delivery Information Submodel 2.0.0 requests. " +
"This endpoint is meant to be accessed by partners via EDC only. ")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Internal Server Error"),
@ApiResponse(responseCode = "501", description = "Unsupported representation")
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content),
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content),
@ApiResponse(responseCode = "501", description = "Unsupported representation", content = @Content)
})
@GetMapping("request/{materialNumberCx}/{representation}")
public ResponseEntity<DeliveryInformation> getDeliveryMapping(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ See the NOTICE file(s) distributed with this work for additional
*/
package org.eclipse.tractusx.puris.backend.demand.controller;

import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import javax.management.openmbean.KeyAlreadyExistsException;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Validator;
import org.eclipse.tractusx.puris.backend.common.util.PatternStore;
import org.eclipse.tractusx.puris.backend.demand.domain.model.OwnDemand;
import org.eclipse.tractusx.puris.backend.demand.domain.model.ReportedDemand;
Expand All @@ -41,7 +37,6 @@ See the NOTICE file(s) distributed with this work for additional
import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialPartnerRelationService;
import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialService;
import org.eclipse.tractusx.puris.backend.masterdata.logic.service.PartnerService;

import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
Expand All @@ -50,10 +45,13 @@ See the NOTICE file(s) distributed with this work for additional
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Validator;
import javax.management.openmbean.KeyAlreadyExistsException;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

@RestController
@RequestMapping("demand")
Expand Down Expand Up @@ -100,9 +98,9 @@ public List<DemandDto> getAllDemands(String ownMaterialNumber, Optional<String>
@Operation(summary = "Creates a new demand")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Demand was created."),
@ApiResponse(responseCode = "400", description = "Malformed or invalid request body."),
@ApiResponse(responseCode = "409", description = "Demand already exists. Use PUT instead."),
@ApiResponse(responseCode = "500", description = "Internal Server Error.")
@ApiResponse(responseCode = "400", description = "Malformed or invalid request body.", content = @Content),
@ApiResponse(responseCode = "409", description = "Demand already exists. Use PUT instead.", content = @Content),
@ApiResponse(responseCode = "500", description = "Internal Server Error.", content = @Content)
})
@ResponseStatus(HttpStatus.CREATED)
public DemandDto createDemand(@RequestBody DemandDto demandDto) {
Expand Down Expand Up @@ -133,9 +131,9 @@ public DemandDto createDemand(@RequestBody DemandDto demandDto) {
@Operation(summary = "Updates a demand by its UUID")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Demand was updated."),
@ApiResponse(responseCode = "400", description = "Malformed or invalid request body."),
@ApiResponse(responseCode = "404", description = "Demand does not exist."),
@ApiResponse(responseCode = "500", description = "Internal Server Error.")
@ApiResponse(responseCode = "400", description = "Malformed or invalid request body.", content = @Content),
@ApiResponse(responseCode = "404", description = "Demand does not exist.", content = @Content),
@ApiResponse(responseCode = "500", description = "Internal Server Error.", content = @Content)
})
@ResponseStatus(HttpStatus.OK)
public DemandDto updateDemand(@RequestBody DemandDto dto) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.eclipse.tractusx.puris.backend.demand.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -49,12 +50,13 @@ public class DemandRequestApiController {
private final Pattern urnPattern = PatternStore.URN_OR_UUID_PATTERN;


@Operation(summary = "This endpoint receives the ShortTermMaterialDemand Submodel 1.0.0 requests")
@Operation(summary = "This endpoint receives the ShortTermMaterialDemand Submodel 1.0.0 requests. " +
"This endpoint is meant to be accessed by partners via EDC only. ")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok"),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "500", description = "Internal Server Error"),
@ApiResponse(responseCode = "501", description = "Unsupported representation")
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content),
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content),
@ApiResponse(responseCode = "501", description = "Unsupported representation", content = @Content)
})
@GetMapping("request/{materialnumbercx}/{representation}")
public ResponseEntity<ShortTermMaterialDemand> getDemandMapping(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ See the NOTICE file(s) distributed with this work for additional
*/
package org.eclipse.tractusx.puris.backend.demandandcapacitynotification.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;

import javax.management.openmbean.KeyAlreadyExistsException;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Validator;
import jakarta.validation.constraints.Pattern;
import org.eclipse.tractusx.puris.backend.common.util.PatternStore;
import org.eclipse.tractusx.puris.backend.demand.logic.services.DemandRequestApiService;
import org.eclipse.tractusx.puris.backend.demandandcapacitynotification.domain.model.OwnDemandAndCapacityNotification;
import org.eclipse.tractusx.puris.backend.demandandcapacitynotification.domain.model.ReportedDemandAndCapacityNotification;
import org.eclipse.tractusx.puris.backend.demandandcapacitynotification.logic.dto.DemandAndCapacityNotificationDto;
Expand All @@ -39,22 +35,21 @@ See the NOTICE file(s) distributed with this work for additional
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Material;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Site;
import org.eclipse.tractusx.puris.backend.masterdata.logic.dto.PartnerDto;
import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialService;
import org.eclipse.tractusx.puris.backend.masterdata.logic.service.PartnerService;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Validator;
import jakarta.validation.constraints.Pattern;
import javax.management.openmbean.KeyAlreadyExistsException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;

@RestController
@RequestMapping("demand-and-capacity-notification")
Expand Down Expand Up @@ -99,9 +94,9 @@ public List<DemandAndCapacityNotificationDto> getAllNotifications(Optional<@Patt
@Operation(summary = "Creates a new notification")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Notification was created."),
@ApiResponse(responseCode = "400", description = "Malformed or invalid request body."),
@ApiResponse(responseCode = "409", description = "Notification already exists. Use PUT instead."),
@ApiResponse(responseCode = "500", description = "Internal Server Error.")
@ApiResponse(responseCode = "400", description = "Malformed or invalid request body.", content = @Content),
@ApiResponse(responseCode = "409", description = "Notification already exists. Use PUT instead.", content = @Content),
@ApiResponse(responseCode = "500", description = "Internal Server Error.", content = @Content)
})
@ResponseStatus(HttpStatus.CREATED)
public DemandAndCapacityNotificationDto createNotification(@RequestBody DemandAndCapacityNotificationDto notificationDto) {
Expand Down Expand Up @@ -131,9 +126,9 @@ public DemandAndCapacityNotificationDto createNotification(@RequestBody DemandAn
@Operation(summary = "Updates a notification by its UUID")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Notification was updated."),
@ApiResponse(responseCode = "400", description = "Malformed or invalid request body."),
@ApiResponse(responseCode = "404", description = "Notification does not exist."),
@ApiResponse(responseCode = "500", description = "Internal Server Error.")
@ApiResponse(responseCode = "400", description = "Malformed or invalid request body.", content = @Content),
@ApiResponse(responseCode = "404", description = "Notification does not exist.", content = @Content),
@ApiResponse(responseCode = "500", description = "Internal Server Error.", content = @Content)
})
@ResponseStatus(HttpStatus.OK)
public DemandAndCapacityNotificationDto updateNotification(@RequestBody DemandAndCapacityNotificationDto dto) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public class DemandAndCapacityNotificationRequestApiController {
@Autowired
private ObjectMapper objectMapper;

@Operation(summary = "This endpoint receives the DemandAndCapacityNotification 2.0.0 requests")
@Operation(summary = "This endpoint receives the DemandAndCapacityNotification 2.0.0 requests. " +
"This endpoint is meant to be accessed by partners via EDC only. ")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok", content = @Content),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Validator;
Expand Down Expand Up @@ -130,8 +131,8 @@ public ResponseEntity<?> updateMaterial(@RequestBody MaterialEntityDto materialD
@Operation(description = "Returns the requested Material dto, specified by the given ownMaterialNumber.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Returns the requested Material."),
@ApiResponse(responseCode = "400", description = "Invalid parameter"),
@ApiResponse(responseCode = "404", description = "Requested Material was not found.")
@ApiResponse(responseCode = "400", description = "Invalid parameter", content = @Content),
@ApiResponse(responseCode = "404", description = "Requested Material was not found.", content = @Content)
})
public ResponseEntity<MaterialEntityDto> getMaterial(@Parameter(name = "ownMaterialNumber",
description = "The Material Number that is used in your own company to identify the Material.",
Expand Down
Loading

0 comments on commit b277446

Please sign in to comment.