Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PMRMS Auth
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ghitha Dinan
PMRMS Auth
Commits
33c81657
Commit
33c81657
authored
Jan 10, 2022
by
Ghitha Dinan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add swagger config
parent
e8877270
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
10 deletions
+96
-10
SpringWebConfig.kt
.../go/kemenag/madrasah/pmrms/auth/config/SpringWebConfig.kt
+18
-0
SwaggerConfig.kt
...id/go/kemenag/madrasah/pmrms/auth/config/SwaggerConfig.kt
+67
-0
AuthController.kt
.../kemenag/madrasah/pmrms/auth/controller/AuthController.kt
+3
-1
CustomExceptionHandler.kt
.../madrasah/pmrms/auth/controller/CustomExceptionHandler.kt
+1
-1
application.properties
src/main/resources/application.properties
+7
-8
No files found.
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/config/SpringWebConfig.kt
View file @
33c81657
...
...
@@ -6,6 +6,8 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean
import
org.springframework.context.annotation.Bean
import
org.springframework.context.annotation.Configuration
import
org.springframework.web.servlet.config.annotation.CorsRegistry
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import
org.springframework.web.servlet.config.annotation.ViewControllerRegistry
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
...
...
@@ -35,4 +37,20 @@ class SpringWebConfig : WebMvcConfigurer {
registrationBean
.
order
=
1
return
registrationBean
}
override
fun
addViewControllers
(
registry
:
ViewControllerRegistry
)
{
registry
.
addRedirectViewController
(
"/v2/api-docs"
,
"/v2/api-docs"
)
registry
.
addRedirectViewController
(
"/swagger-resources/configuration/ui"
,
"/swagger-resources/configuration/ui"
)
registry
.
addRedirectViewController
(
"/swagger-resources/configuration/security"
,
"/swagger-resources/configuration/security"
)
registry
.
addRedirectViewController
(
"/swagger-resources"
,
"/swagger-resources"
)
}
override
fun
addResourceHandlers
(
registry
:
ResourceHandlerRegistry
)
{
registry
.
addResourceHandler
(
"/swagger-ui.html**"
)
.
addResourceLocations
(
"classpath:/META-INF/resources/swagger-ui.html"
)
registry
.
addResourceHandler
(
"/webjars/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
)
}
}
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/config/SwaggerConfig.kt
0 → 100644
View file @
33c81657
package
id.go.kemenag.madrasah.pmrms.auth.config
import
org.springframework.beans.factory.annotation.Value
import
org.springframework.context.annotation.Bean
import
org.springframework.context.annotation.Configuration
import
springfox.documentation.builders.PathSelectors
import
springfox.documentation.builders.RequestHandlerSelectors
import
springfox.documentation.service.*
import
springfox.documentation.spi.DocumentationType
import
springfox.documentation.spi.service.contexts.SecurityContext
import
springfox.documentation.spring.web.plugins.Docket
import
springfox.documentation.swagger2.annotations.EnableSwagger2
import
java.util.*
@Suppress
(
"UNCHECKED_CAST"
,
"DEPRECATION"
)
@Configuration
@EnableSwagger2
class
SwaggerConfig
{
@Value
(
"\${swagger.host}"
)
private
val
host
:
String
?
=
null
@Value
(
"\${swagger.protocol}"
)
private
val
protocol
:
String
?
=
null
@Bean
fun
api
():
Docket
?
{
return
Docket
(
DocumentationType
.
SWAGGER_2
)
.
host
(
host
)
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"id.go.kemenag.madrasah.pmrms.auth.controller"
))
.
paths
(
PathSelectors
.
any
())
.
build
()
.
useDefaultResponseMessages
(
false
)
.
apiInfo
(
apiInfo
())
.
protocols
(
setOf
(
protocol
))
.
securitySchemes
(
listOf
(
apiKey
())
as
List
<
SecurityScheme
>?)
.
securityContexts
(
Collections
.
singletonList
(
securityContext
()))
}
private
fun
apiInfo
():
ApiInfo
{
return
ApiInfo
(
"PMRMS API - Auth"
,
"Auth Service for Application PMRMS"
,
"1.0"
,
"Terms of service"
,
Contact
(
"Application PMRMS"
,
"-"
,
"-"
),
""
,
""
,
Collections
.
emptyList
()
)
}
private
fun
apiKey
():
ApiKey
{
return
ApiKey
(
"Bearer"
,
"Authorization"
,
"header"
)
}
private
fun
securityContext
():
SecurityContext
?
{
return
SecurityContext
.
builder
().
securityReferences
(
defaultAuth
()).
forPaths
(
PathSelectors
.
regex
(
"/.*"
)).
build
()
}
private
fun
defaultAuth
():
List
<
SecurityReference
?>
{
return
listOf
(
SecurityReference
(
"Bearer"
,
arrayOfNulls
(
0
)))
}
}
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/contoller/AuthController.kt
→
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/cont
r
oller/AuthController.kt
View file @
33c81657
package
id.go.kemenag.madrasah.pmrms.auth.contoller
package
id.go.kemenag.madrasah.pmrms.auth.cont
r
oller
import
id.go.kemenag.madrasah.pmrms.auth.model.request.auth.LoginRequest
import
id.go.kemenag.madrasah.pmrms.auth.model.response.ReturnData
import
id.go.kemenag.madrasah.pmrms.auth.service.AuthService
import
io.swagger.annotations.Api
import
org.springframework.beans.factory.annotation.Autowired
import
org.springframework.http.ResponseEntity
import
org.springframework.web.bind.annotation.*
import
javax.validation.Valid
@Api
(
tags
=
[
"Auth"
],
description
=
"Auth API"
)
@RestController
@RequestMapping
(
path
=
[
"auth"
])
class
AuthController
{
...
...
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/contoller/CustomExceptionHandler.kt
→
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/cont
r
oller/CustomExceptionHandler.kt
View file @
33c81657
package
id.go.kemenag.madrasah.pmrms.auth.contoller
package
id.go.kemenag.madrasah.pmrms.auth.cont
r
oller
import
id.go.kemenag.madrasah.pmrms.auth.exception.BaseException
import
id.go.kemenag.madrasah.pmrms.auth.model.response.ErrorMessage
...
...
src/main/resources/application.properties
View file @
33c81657
# SERVER CONFIG
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS
=
false
spring.profiles.active
=
development
server.port
=
8080
#server.port=8080
server.port
=
8081
# DATABASE CONFIG
# local
...
...
@@ -28,13 +29,6 @@ spring.jpa.properties.hibernate.format_sql=true
spring.servlet.multipart.max-file-size
=
500MB
spring.servlet.multipart.max-request-size
=
500MB
# MAIl CONFIG
spring.mail.host
=
mail.smtp2go.com
spring.mail.port
=
2525
spring.mail.username
=
kominfo-05
spring.mail.password
=
eXFwenN6cm4yYmMw
spring.mail.from
=
no-reply@layanan.go.id
spring.mail.properties.mail.smtp.auth
=
true
spring.mail.properties.mail.smtp.connectiontimeout
=
25000
spring.mail.properties.mail.smtp.timeout
=
25000
...
...
@@ -45,3 +39,8 @@ spring.mail.properties.mail.smtp.starttls.enable=true
app.name
=
PMRMS
server.max-http-header-size
=
10000KB
# Swagger
swagger.host
=
localhost:8081
swagger.protocol
=
http
spring.main.allow-circular-references
=
true
spring.mvc.pathmatch.matching-strategy
=
ant_path_matcher
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment