Compare commits

..

8 commits

Author SHA1 Message Date
4dafc2d58d
PMT-9: Update CI Filters, to exclude all Generated Code better, and Ignoring one Warning for Specific Reasons
All checks were successful
Quality Check / Validate OAS (push) Successful in 45s
Quality Check / Validate OAS (pull_request) Successful in 1m11s
Quality Check / Testing (push) Successful in 1m46s
Quality Check / Linting (push) Successful in 2m5s
Quality Check / Testing (pull_request) Successful in 1m49s
Quality Check / Static Analysis (push) Successful in 2m21s
Quality Check / Linting (pull_request) Successful in 2m4s
Quality Check / Static Analysis (pull_request) Successful in 2m7s
2024-09-30 09:11:11 +02:00
61852ade0e
PMT-9: Extend Example usage, to show how to use the API Client 2024-09-30 09:10:32 +02:00
a2cb7e6a59
PMT-9: Implement an API Client Factory for setting up the API Client with its Config 2024-09-30 09:10:01 +02:00
319f187cae
PMT-9: Wrap Reading of JWT from User Auth, so it can be passed later on 2024-09-30 09:09:01 +02:00
d3755984d9
PMT-9: Move Template to Config Bean, so it can be reused by Generated Code 2024-09-30 09:08:16 +02:00
12d97a88d1
PMT-9: Add Local HTTP File for Getting an Access Token 2024-09-30 09:07:40 +02:00
558cd46a7c
PMT-9: Add Generation of Employee API Client 2024-09-30 09:07:08 +02:00
b04ab575cf
PMT-9: Add Employee API Doc Localy (With Bugfixes) 2024-09-30 09:06:32 +02:00
6 changed files with 60 additions and 26 deletions

View file

@ -201,6 +201,8 @@ paths:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/EmployeeResponseDTO'
post:
tags:
@ -467,6 +469,5 @@ components:
securitySchemes:
bearerAuth:
type: http
name: bearerAuth
scheme: bearer
bearerFormat: JWT

View file

@ -1,9 +1,8 @@
package de.hmmh.pmt;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.hmmh.pmt.auth.JwtToken;
import de.hmmh.pmt.employee.ApiClient;
import de.hmmh.pmt.employee.api.EmployeeControllerApi;
import de.hmmh.pmt.employee.ApiClientFactory;
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
import de.hmmh.pmt.oas.DefaultApi;
import de.hmmh.pmt.dtos.HelloOut;
import jakarta.servlet.http.HttpServletRequest;
@ -17,13 +16,8 @@ import java.util.Optional;
@Controller
@RequestMapping("${openapi.projectManagement.base-path:/api/v1}")
public class ApiController implements DefaultApi {
@Autowired
private ApiClient apiClient;
@Autowired
private JwtToken apiToken;
@Autowired
private EmployeeControllerApi employeeApi;
private ApiClientFactory apiClientFactory;
@Override
public Optional<ObjectMapper> getObjectMapper() {
@ -37,15 +31,14 @@ public class ApiController implements DefaultApi {
@Override
public ResponseEntity<HelloOut> getHello() {
apiClient.setAccessToken(apiToken.getToken());
apiClient.setBasePath("https://employee.szut.dev");
//TODO: Get Authentication working
employeeApi.setApiClient(apiClient);
String data = employeeApi.findAll1().toString();
StringBuilder employees = new StringBuilder();
for (EmployeeResponseDTO employeeResponseDTO : apiClientFactory.getEmployeeApi().findAll1()) {
employees.append(employeeResponseDTO.toString());
}
HelloOut hello = new HelloOut();
hello.setMsg(data);
hello.setMsg(employees.toString());
return ResponseEntity.ok(hello);
}
}

View file

@ -4,6 +4,7 @@ import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
@ -12,11 +13,8 @@ import java.io.IOException;
@Component
public class JwtTokenFilter extends OncePerRequestFilter {
private final JwtToken token;
public JwtTokenFilter(JwtToken token) {
this.token = token;
}
@Autowired
private JwtToken token;
@Override
protected void doFilterInternal(

View file

@ -0,0 +1,37 @@
package de.hmmh.pmt.employee;
import de.hmmh.pmt.auth.JwtToken;
import de.hmmh.pmt.employee.api.EmployeeControllerApi;
import de.hmmh.pmt.employee.api.QualificationControllerApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ApiClientFactory {
@Autowired
private ApiClient apiClient;
@Autowired
private JwtToken apiToken;
@Autowired
private EmployeeControllerApi employee;
@Autowired
private QualificationControllerApi qualification;
public EmployeeControllerApi getEmployeeApi() {
prepareApiClient();
employee.setApiClient(apiClient);
return employee;
}
public QualificationControllerApi getQualificationApi() {
prepareApiClient();
qualification.setApiClient(apiClient);
return qualification;
}
private void prepareApiClient() {
apiClient.setAccessToken(apiToken.getToken());
apiClient.setBasePath("https://employee.szut.dev");
}
}

View file

@ -5,6 +5,5 @@
>
<suppressions>
<suppress files="[\\/]de[\\/]hmmh[\\/]pmt[\\/]oas" checks="."/>
<suppress files="[\\/]de[\\/]hmmh[\\/]pmt[\\/]dtos" checks="."/>
<suppress files="build[\\/]" checks="."/>
</suppressions>

View file

@ -1,5 +1,11 @@
<FindBugsFilter xmlns="https://raw.githubusercontent.com/spotbugs/spotbugs/4.8.6/spotbugs/etc/findbugsfilter.xsd">
<Match>
<Class name="de.hmmh.pmt.OpenAPISpringBoot$ExitException"/>
<!-- We Want This Exposure of Resources the Way it is for our usage -->
<Class name="de.hmmh.pmt.employee.ApiClientFactory"/>
<Bug code="M,V,EI"/>
</Match>
<Match>
<!--Ignore Auto Generated Code -->
<Source name="~.*build/.*"/>
</Match>
</FindBugsFilter>