Add support for API documentation (#2082)

pull/2086/head
John Niang 2022-05-11 16:06:11 +08:00 committed by GitHub
parent b4e9b54ffe
commit 3cf2f9d7e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 15 deletions

View File

@ -55,6 +55,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation "org.springframework.boot:spring-boot-starter-jetty"
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.0-M2'
implementation "org.flywaydb:flyway-core"
implementation "org.flywaydb:flyway-mysql"

View File

@ -83,7 +83,10 @@ public class WebSecurityConfig {
http
.authorizeHttpRequests((authorize) -> authorize
.antMatchers(providerSettings.getTokenEndpoint()).permitAll()
// for static path
.antMatchers("/static/js/**").permitAll()
// for swagger ui
.antMatchers("/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html").permitAll()
.antMatchers("/api/**", "/apis/**").access(requestInfoAuthorizationManager())
.anyRequest().access(requestInfoAuthorizationManager())
)

View File

@ -0,0 +1,35 @@
server:
port: 8090
spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
output:
ansi:
enabled: always
datasource:
type: com.zaxxer.hikari.HikariDataSource
# H2 database configuration.
driver-class-name: org.h2.Driver
url: jdbc:h2:file:~/halo-next/db/halo;AUTO_SERVER=TRUE
username: admin
password: 123456
jpa:
hibernate:
ddl-auto: update
open-in-view: false
show-sql: true
halo:
security:
oauth2:
jwt:
public-key-location: classpath:app.pub
private-key-location: classpath:app.key
logging:
level:
run.halo.app: DEBUG
springdoc:
api-docs:
enabled: true

View File

@ -6,10 +6,6 @@ spring:
output:
ansi:
enabled: always
devtools:
restart:
enabled: true
log-condition-evaluation-delta: false
datasource:
type: com.zaxxer.hikari.HikariDataSource
@ -34,20 +30,14 @@ spring:
hibernate:
ddl-auto: update
open-in-view: false
flyway:
enabled: true
locations:
- classpath:db/migration/common
- classpath:db/migration/{vendor}
halo:
security:
oauth2:
jwt:
public-key-location: classpath:app.pub
private-key-location: classpath:app.key
logging:
level:
run.halo.app: DEBUG
org.hibernate: INFO
org.hibernate.type.descriptor.sql.BasicBinder: INFO
org.hibernate.type.descriptor.sql.BasicExtractor: INFO
springdoc:
api-docs:
enabled: false