티스토리 뷰

공부

[WebFlux] open api docs (swagger)

승가비 2022. 7. 10. 02:57
728x90

 

springdoc:
  swagger-ui:
    url: /docs/merged
    path: /
  api-docs:
    custom:
      title: API Test
      version: 1.0
      description: API Test
      service: http://test.seunggabi.com
      name: test
      url: https://github.com/seunggabi/test
      email: seunggabi@gmail.com

https://medium.com/dandelion-tutorials/documenting-functional-rest-endpoints-with-springdoc-openapi-21657c0ebc8a

 

Documenting functional REST endpoints with springdoc-openapi

What is springdoc? springdoc-openapi java library helps to automate the generation of API documentation using spring boot projects…

medium.com

@Bean
    @Order(-1)
    @RouterOperations(
        RouterOperation(
            path = TEST_V1,
            method = [RequestMethod.GET],
            operation = Operation(
                operationId = TEST_V1,
                tags = ["test", "v1"],
                parameters = [
                    Parameter(
                        name = "start",
                        `in` = ParameterIn.QUERY,
                        required = false,
                        example = "1"
                    ),
                    Parameter(
                        name = "display",
                        `in` = ParameterIn.QUERY,
                        required = false,
                        example = "20"
                    )
                ],
                responses = [
                    ApiResponse(
                        responseCode = "200",
                    ),
                    ApiResponse(
                        responseCode = "404",
                    )
                ]
            )
        ),
    )
@Configuration
@EnableConfigurationProperties(DocsProperties::class)
class DocsConfig(
    val properties: DocsProperties
) {
    @Bean
    fun openAPI(): OpenAPI {
        with(properties) {
            val info = Info()
                .title(title)
                .version(version)
                .description(description)
                .termsOfService(service)
                .contact(
                    Contact()
                        .name(name)
                        .url(url)
                        .email(email)
                )
                .license(
                    License()
                        .name("Apache License Version 2.0")
                        .url("http://www.apache.org/licenses/LICENSE-2.0")
                )

            return OpenAPI()
                .info(info)
        }
    }
}

 

728x90

'공부' 카테고리의 다른 글

[k8s] NodePort(node), Port(service), TargetPort(pod)  (0) 2022.07.10
[kotlin] coding convention  (0) 2022.07.10
[JPA] manual SQL (nativeQuery=True)  (0) 2022.07.10
[js] npm(직렬) vs yarn(병렬)  (0) 2022.07.10
[kotlin] ReflectionUtils.kt  (0) 2022.07.09
댓글