OpenAPI Specification

OpenAPI 또는 OpenAPI Specification(OAS) 는 Swagger 에서 발전한 API 명세 형태를 의미한다.

Document Structure

It is RECOMMENDED that the root OpenAPI document be named: openapi.json or openapi.yaml.

Swagger

What is Swagger ? Swagger 란 Open Api Specification(OAS)를 위한 프레임워크이다.

Swagger is a set of open-source tools built around the OpenAPI Specification that can help you design, build, document and consume REST APIs.

Swagger does this by asking your API to return a YAML or JSON that contains a detailed description of your entire API. This file is essentially a resource listing of your API which adheres to OpenAPI Specification.

Check swagger.io/open-source-integrations for a list of tools that let you generate Swagger from code.

ReDoc

Swagger2MarkUp

Swagger Code Generation

What Is the Difference Between Swagger and OpenAPI?

OpenAPI 는 RESTful API 설계를 위한 업계 표준 사양을 나타내고 Swagger 는 SmartBear 도구 세트를 의미.

SpringFox

SpringFox = Spring & Swagger

Philosophically, we want to discourage using (swagger-core) annotations that are not material to the service description at runtime.

SpringDoc - SpringFramework Open API Specification

OpenAPI 3 어노테이션 없이, Spring MVC/WebFlux 어노테이션을 인식하여 자동으로 OpenAPI Spec 3 문서 생성.

springdoc-openapi java library helps to automate the generation of API documentation using spring boot projects. springdoc-openapi works by examining an application at runtime to infer API semantics based on spring configurations, class structure and various annotations.

Automatically generates documentation in JSON/YAML and HTML format APIs. This documentation can be completed by comments using swagger-api annotations.

Spring REST Docs

Spring REST Docs 는 테스트 코드 기반으로 RESTful 문서생성을 돕는 도구로 기본적으로 Asciidoctor 를 사용하여 HTML 를 생성한다. Spring MVC 테스트 프레임워크로 생성된 snippet 을 사용해서 올바르지 않으면 생성된 테스트가 실패하여 정확성을 보장해준다.

Rest Docs 는 테스트 코드 기반으로 문서가 작성되기 때문에 문서와 실제 코드의 일치성이 높고 테스트 코드로 문서가 표현되기 때문에 Production 코드에 어떠한 코드(Ex. 문서 관련 Annotation) 추가도 필요가 없다는 장점이 있다.

Spring REST Docs with Swagger