# Building APIs with Swagger

![](https://2387071138-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M2vWCT8lbIfip1tMlDx%2F-M5rQND6X66UzbLZzHV3%2F-M5rQd5wDya64cdzh3ZW%2FScreen%20Shot%202020-04-26%20at%209.59.47%20AM.png?alt=media\&token=b626cc81-e4e2-46cc-8b72-484192a4241a)

Swagger分三個部分，Swagger editor、Swagger UI、Swagger Codegen。Swagger editor去定義api specification，Swagger UI把Swagger editor定義的api變成網站，方便寫程式的人看，Swagger codegen是將這些api definition變成code，讓我們之後去implement business logic。

## Paid online course

1. [Building APIs with Swagger and the OpenAPI Specification](https://www.linkedin.com/learning/building-apis-with-swagger-and-the-openapi-specification/auto-mocking-apis?u=2101921)
2. [Spring: Spring Cloud - Document microservices with Swagger](https://www.linkedin.com/learning/spring-spring-cloud/document-microservices-with-swagger?u=2101921)
3. [AWS API Gateway with HTTP, Lambda, DynamoDB, and iOS](https://www.linkedin.com/learning/aws-api-gateway-with-http-lambda-dynamodb-and-ios?u=2101921) - Generate an SDK with Swagger

Swagger基本內容先看 \[1]，\[1] 很詳細說明Swagger UI，但沒有code generation的內容。

如果想要將swagger UI deploy到spring boot看 \[2]。

Swagger code generation請看 \[3]，但 \[3] 講的東西其實很少。其實用Maven將generated file產出之後，之後去implement即可，也不太需要學什麼。

{% hint style="warning" %}
避免部署Swagger UI的方式就是copy你的yaml file，past到swagger editor即可。

[https://editor.swagger.io/](https://editor.swagger.io/)
{% endhint %}

## Prerequisites

1. REST
2. [YAML](https://rollout.io/blog/yaml-tutorial-everything-you-need-get-started/)
3. JSON

## References

[https://github.com/OAI](https://github.com/OAI)

[https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schema](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schema)



