Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: code refactor - removing swagger #418

Merged
merged 5 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down Expand Up @@ -207,13 +212,6 @@
<scope>test</scope>
</dependency>

<!-- Documentation -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.6.0</version>
</dependency>

<!-- Authentication and Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,22 @@

import ca.bc.gov.restapi.results.common.enums.ForestClientStatusEnum;
import ca.bc.gov.restapi.results.common.enums.ForestClientTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.With;

/**
* This record represents a Forest Client object.
*/
@Schema(description = "One of the many agencies that work with the ministry.")
@Builder
@With
public record ForestClientDto(
@Schema(description = "An eight-digit number that identifies the client.", example = "00149081")
String clientNumber,
@Schema(
description =
"The client last name if it's an individual or the company name if it's a company.",
example = "WESTERN FOREST PRODUCTS INC.")
String clientName,
@Schema(
description = "The first name of the individual, or null if it's a company.",
example = "Maria")
String legalFirstName,
@Schema(
description = "The middle name of the individual, or null if it's a company",
example = "Bricks")
String legalMiddleName,
@Schema(
description =
"A code indicating the status of ministry client. Examples include but are not"
+ " limited to: Active, Deactivated, Deceased...",
example = "ACT")
ForestClientStatusEnum clientStatusCode,
@Schema(
description =
"A code indicating a type of ministry client. Examples include but are not limited"
+ " to: Corporation, Individual, Association, First Nation..",
example = "C")
ForestClientTypeEnum clientTypeCode,
@Schema(
description = "An acronym for this client; works as an alternative identifier.",
example = "WFP")
String acronym) {
String acronym
) {

}
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
package ca.bc.gov.restapi.results.common.endpoint;

import ca.bc.gov.restapi.results.common.service.RestService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/** This class holds resources for calling WFS. */
/**
* This class holds resources for calling WFS.
*/
@RestController
@RequestMapping("/api/feature-service")
@AllArgsConstructor
@Tag(
name = "Feature Service to call WFS (Common)",
description = "Endpoints for handle WFS (Web Feature Service) within BC Geo Warehouse")
public class FeatureServiceEndpoint {

private final RestService restService;
Expand All @@ -32,29 +24,9 @@ public class FeatureServiceEndpoint {
* @return JSON object with response from WFS request
*/
@GetMapping("/polygon-and-props/{openingId}")
@Operation(
summary = "Fetch Opening data from WFS",
description =
"Fetch Opening data (polygon raster data and properties) from WFS. These are the props "
+ "being fetched: OPENING_ID, GEOMETRY, REGION_NAME, REGION_CODE, DISTRICT_NAME, "
+ "DISTRICT_CODE, CLIENT_NAME, CLIENT_NUMBER, and OPENING_WHEN_CREATED",
responses = {
@ApiResponse(
responseCode = "200",
description = "An object with the response from WFS request."),
@ApiResponse(
responseCode = "401",
description = "Access token is missing or invalid",
content = @Content(schema = @Schema(implementation = Void.class)))
})
public Object getOpeningPolygonAndProperties(
@Parameter(
name = "openingId",
in = ParameterIn.PATH,
description = "The opening Id.",
required = true)
@PathVariable
String openingId) {
@PathVariable
String openingId) {
return restService.getOpeningPolygonAndProperties(openingId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,18 @@
import ca.bc.gov.restapi.results.common.dto.ForestClientDto;
import ca.bc.gov.restapi.results.common.exception.ForestClientNotFoundException;
import ca.bc.gov.restapi.results.common.service.ForestClientService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/** This class holds resources for the Forest Client API interaction. */
/**
* This class holds resources for the Forest Client API interaction.
*/
@RestController
@RequestMapping("/api/forest-clients")
@AllArgsConstructor
@Tag(
name = "Forest Client (Common)",
description = "Endpoints for fetching client information from Forest Client API")
public class ForestClientEndpoint {

private final ForestClientService forestClientService;
Expand All @@ -35,30 +27,7 @@ public class ForestClientEndpoint {
* @throws ForestClientNotFoundException when client not found
*/
@GetMapping("/{clientNumber}")
@Operation(
summary = "Fetch a forest client given its number.",
description =
"Fetch a forest client directly from the ForestClient API given the client number.",
responses = {
@ApiResponse(
responseCode = "200",
description = "An object with all client properties provided by the ForestClient API."),
@ApiResponse(
responseCode = "400",
description = "Something wrong with the client number, make sure you're sending it."),
@ApiResponse(
responseCode = "401",
description = "Access token is missing or invalid",
content = @Content(schema = @Schema(implementation = Void.class)))
})
public ForestClientDto getForestClient(
@Parameter(
name = "clientNumber",
in = ParameterIn.PATH,
description = "The client number to be fetched.",
required = true)
@PathVariable
String clientNumber) {
public ForestClientDto getForestClient(@PathVariable String clientNumber) {
return forestClientService
.getClientByNumber(clientNumber)
.orElseThrow(ForestClientNotFoundException::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package ca.bc.gov.restapi.results.common.endpoint;

import ca.bc.gov.restapi.results.common.dto.WmsLayersWhitelistUserDto;
import io.swagger.v3.oas.annotations.Hidden;
import java.util.List;
import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/** This class holds resources for getting secrets from the backend. */
/**
* This class holds resources for getting secrets from the backend.
*/
@RestController
@RequestMapping("/api/secrets")
@Hidden
public class SecretsServiceEndpoint {

@Value("${nr.results.config.wms-layers.whitelist}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
package ca.bc.gov.restapi.results.common.pagination;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import lombok.Getter;
import lombok.Setter;

/** Holds an API response with pagination information and data. */
@Getter
@Setter
@Schema(description = "Holds an API response with pagination information and data.")
public class PaginatedResult<T> {

@Schema(description = "Current page index, zero-based.", example = "2")
private int pageIndex;

@Schema(description = "The amount of records per page.", example = "15")
private int perPage;

@Schema(description = "The amount of pages", example = "3")
private int totalPages;

@Schema(description = "Defines if there's more records to fetch", example = "false")
private boolean hasNextPage;

@Schema(description = "List of records, or empty list if no records.")
private List<T> data;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package ca.bc.gov.restapi.results.common.pagination;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand All @@ -13,16 +10,6 @@
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Parameter(
in = ParameterIn.QUERY,
description = "Zero-based page index indicating the page to be returned.",
name = "page",
schema = @Schema(type = "integer", defaultValue = "0", minimum = "0"))
@Parameter(
in = ParameterIn.QUERY,
description = "The maximum number of results in a page.",
name = "perPage",
schema = @Schema(type = "integer", defaultValue = "5", minimum = "1"))
public @interface PaginatedViaQuery {

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ca.bc.gov.restapi.results.common.pagination;

import io.swagger.v3.oas.annotations.Hidden;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.PositiveOrZero;

Expand All @@ -10,7 +9,6 @@
* @param page The page to be returned. Zero-based, and must be non-negative; defaults to 0
* @param perPage The maximum number of results in each page. Defaults to 20
*/
@Hidden
public record PaginationParameters(@PositiveOrZero Integer page, @Positive Integer perPage) {

/**
Expand Down
Loading
Loading