This commit is contained in:
Andrey Kassaev 2024-01-01 17:55:36 +04:00
parent 60fe7d5abb
commit dff527f380
4 changed files with 25 additions and 2 deletions

View File

@ -6,6 +6,7 @@ plugins {
kotlin("jvm") version "1.9.22"
kotlin("plugin.spring") version "1.9.22"
kotlin("plugin.jpa") version "1.9.22"
id("org.springdoc.openapi-gradle-plugin") version "1.8.0"
}
group = "com.kassaev"
@ -37,6 +38,8 @@ dependencies {
implementation("org.postgresql:postgresql:42.7.1")
implementation("org.springframework.boot:spring-boot-starter-data-jpa:3.2.1")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0")
}
tasks.withType<KotlinCompile> {
@ -49,3 +52,16 @@ tasks.withType<KotlinCompile> {
tasks.withType<Test> {
useJUnitPlatform()
}
//for gradlew clean generateOpenApiDocs
tasks {
forkedSpringBootRun {
doNotTrackState("See https://github.com/springdoc/springdoc-openapi-gradle-plugin/issues/102")
}
}
//for gradlew clean generateOpenApiDocs
val port = "${System.getenv("SPRING_PORT")}"
openApi {
apiDocsUrl.set("http://localhost:$port/v3/api-docs")
}

View File

@ -25,7 +25,7 @@ class SecurityConfiguration(
.csrf { it.disable() }
.authorizeHttpRequests {
it
.requestMatchers("/api/v1.0.0/auth", "/api/v1.0.0/auth/refresh", "/error")
.requestMatchers("/api/v1.0.0/auth", "/api/v1.0.0/auth/refresh", "/error", "/swagger-ui/**", "/swagger*", "/v3/api-docs", "/v3/api-docs/**")
.permitAll()
.requestMatchers(HttpMethod.POST, "/api/v1.0.0/user")
.permitAll()

View File

@ -5,11 +5,15 @@ import jakarta.persistence.*
@Entity
@Table(name="users")
data class User(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Long?,
val email: String,
val password: String,
@Enumerated(EnumType.STRING)
val role: Role
)

View File

@ -12,4 +12,7 @@ spring:
hibernate:
ddl-auto: update
server:
port: ${SPRING_PORT}
port: ${SPRING_PORT}
springdoc:
swagger-ui:
enabled: false