forked from HowBaChu/Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swagger에서 API 요청 시 사용할 도메인을 선택하는 옵션을 추가했습니다.
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/HowBaChu/howbachu/config/Workaround.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.HowBaChu.howbachu.config; | ||
|
||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.servers.Server; | ||
import org.springframework.stereotype.Component; | ||
import springfox.documentation.oas.web.OpenApiTransformationContext; | ||
import springfox.documentation.oas.web.WebMvcOpenApiTransformationFilter; | ||
import springfox.documentation.spi.DocumentationType; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import java.util.Arrays; | ||
|
||
@Component | ||
public class Workaround implements WebMvcOpenApiTransformationFilter { | ||
@Override | ||
public OpenAPI transform(OpenApiTransformationContext<HttpServletRequest> context) { | ||
OpenAPI openAPI = context.getSpecification(); | ||
Server localServer = new Server(); | ||
localServer.setDescription("local server"); | ||
localServer.setUrl("http://localhost:8080"); | ||
|
||
Server prodHttpsServer = new Server(); | ||
prodHttpsServer.setDescription("prod Https Server"); | ||
prodHttpsServer.setUrl("https://howbachu.kro.kr"); | ||
|
||
Server prodHttpServer = new Server(); | ||
prodHttpServer.setDescription("prod Http Server"); | ||
prodHttpServer.setUrl("http://54.180.26.251:8080"); | ||
|
||
openAPI.setServers(Arrays.asList(localServer, prodHttpsServer, prodHttpServer)); | ||
return openAPI; | ||
} | ||
|
||
@Override | ||
public boolean supports(DocumentationType documentationType) { | ||
return documentationType.equals(DocumentationType.OAS_30); | ||
} | ||
} |