-
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.
10. OpenAPI и Swagger - документирование REST API [#505117]
- Loading branch information
1 parent
9fc10d2
commit 07b52a1
Showing
9 changed files
with
168 additions
and
2 deletions.
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
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,50 @@ | ||
package ru.job4j.api.config; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Contact; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import io.swagger.v3.oas.models.info.License; | ||
import io.swagger.v3.oas.models.servers.Server; | ||
|
||
@Configuration | ||
public class OpenAPIConfig { | ||
|
||
@Value("${socialmedia.openapi.dev-url}") | ||
private String devUrl; | ||
|
||
@Value("${socialmedia.openapi.prod-url}") | ||
private String prodUrl; | ||
|
||
@Bean | ||
public OpenAPI myOpenAPI() { | ||
Server devServer = new Server(); | ||
devServer.setUrl(devUrl); | ||
devServer.setDescription("Server URL in Development environment"); | ||
|
||
Server prodServer = new Server(); | ||
prodServer.setUrl(prodUrl); | ||
prodServer.setDescription("Server URL in Production environment"); | ||
|
||
Contact contact = new Contact(); | ||
contact.setEmail("[email protected]"); | ||
contact.setName("MyName"); | ||
contact.setUrl("https://www.mydomen.com"); | ||
|
||
License mitLicense = new License().name("MIT License").url("https://choosealicense.com/licenses/mit/"); | ||
|
||
Info info = new Info() | ||
.title("SocialMedia Management API") | ||
.version("1.0") | ||
.contact(contact) | ||
.description("This API exposes endpoints to manage project.").termsOfService("https://mydomen.com") | ||
.license(mitLicense); | ||
|
||
return new OpenAPI().info(info).servers(List.of(devServer, prodServer)); | ||
} | ||
} |
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
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
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
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
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
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
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