Skip to content

Commit

Permalink
Merge pull request #12 from tofiksa/add-swagger
Browse files Browse the repository at this point in the history
Add swagger
  • Loading branch information
tofiksa authored Feb 8, 2024
2 parents c123ec8 + 36ee0c0 commit aefc6df
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
16 changes: 10 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
</properties>

<dependencies>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand All @@ -30,6 +35,10 @@
<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.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
Expand Down Expand Up @@ -70,12 +79,7 @@
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.2.1</version>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.and()
.authorizeRequests()
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.requestMatchers("/error").permitAll()
.requestMatchers("/swagger-ui.html", "/swagger-ui/**", "/swagger-resources/**", "/swagger-resources", "/v3/api-docs/*", "/v3/api-docs").hasRole("ANONYMOUS")
.requestMatchers("/register/**").hasRole("ANONYMOUS")
.requestMatchers("/auth/**").hasRole("ANONYMOUS").anyRequest().authenticated().and()
.apply(new JwtSecurityConfigurer(jwtTokenProvider));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.josefushighscore.controller;

import jakarta.validation.Valid;
import no.josefushighscore.dto.LoginUserDto;
import no.josefushighscore.dto.UserDto;
import no.josefushighscore.service.APIResponse;
Expand All @@ -14,8 +15,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/auth")
public class AuthenticationController {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/no/josefushighscore/model/User.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package no.josefushighscore.model;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -9,7 +10,6 @@
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void setUp() {
user.setLastname("TestUserLastname");
user.setEmail("[email protected]");
user.setPassword("TestPassword");
user.setUsername("TestUsername");

this.entityManager.persist(user);
}
Expand Down

0 comments on commit aefc6df

Please sign in to comment.